Skip to content
Berke edited this page Jun 23, 2026 · 1 revision

Lua Input Bindings

The Input table exposes keyboard and mouse input handling to Lua scripts. Keys are referenced using string names (e.g. "W", "Space", "Left"), which are internally mapped to SDL scancodes.


Key Input

GetKeyDown

local pressed = Input.GetKeyDown(key)

Returns true on the frame the key is first pressed.

Parameters

Name Type Description
key string Key name (e.g. "A", "Space")

Returns

boolean

true if the key was just pressed this frame.


GetKey

local held = Input.GetKey(key)

Returns true while the key is being held down.

Parameters

Name Type
key string

Returns

boolean

true if the key is currently held.


GetKeyUp

local released = Input.GetKeyUp(key)

Returns true on the frame the key is released.

Parameters

Name Type
key string

Returns

boolean

true if the key was released this frame.


Multi-Key Input

GetDoubleKeyDown

local pressed = Input.GetDoubleKeyDown(keyA, keyB)

Returns true when a specific key combination is first pressed.

Parameters

Name Type
keyA string
keyB string

Returns

boolean

true if both keys are triggered as a combined input.


GetDoubleKey

local held = Input.GetDoubleKey(keyA, keyB)

Returns true while both keys are held.

Parameters

Name Type
keyA string
keyB string

Returns

boolean

true if both keys are currently held.


Mouse Input

GetMouseButtonDown

local pressed = Input.GetMouseButtonDown(button)

Triggered when a mouse button is first pressed.

Parameters

Name Type
button number

Returns

boolean

GetMouseButton

local held = Input.GetMouseButton(button)

Returns true while the mouse button is held.

Parameters

Name Type
button number

Returns

boolean

GetMouseButtonUp

local released = Input.GetMouseButtonUp(button)

Triggered when a mouse button is released.

Parameters

Name Type
button number

Returns

boolean

GetMousePosition

local pos = Input.GetMousePosition()

Returns the current mouse position.

Returns

Vector2

Key Names

Keys are passed as strings:

Letters

"A" "B" "C" ... "Z"

Numbers

"0" "1" "2" ... "9"

Common Keys

"Space"
"Enter"
"Escape"
"Tab"
"Backspace"

Arrow Keys

"Left"
"Right"
"Up"
"Down"

Modifiers

"LShift" "RShift"
"LCtrl"  "RCtrl"
"LAlt"   "RAlt"

Mouse Buttons

Input.MouseLeft
Input.MouseMiddle
Input.MouseRight

Example

if Input.GetKeyDown("W") then
    print("Move forward")
end

if Input.GetMouseButton(Input.MouseLeft) then
    print("Shooting")
end

local mousePos = Input.GetMousePosition()

Clone this wiki locally