-
Notifications
You must be signed in to change notification settings - Fork 5
Input
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.
local pressed = Input.GetKeyDown(key)Returns true on the frame the key is first pressed.
| Name | Type | Description |
|---|---|---|
| key | string | Key name (e.g. "A", "Space") |
booleantrue if the key was just pressed this frame.
local held = Input.GetKey(key)Returns true while the key is being held down.
| Name | Type |
|---|---|
| key | string |
booleantrue if the key is currently held.
local released = Input.GetKeyUp(key)Returns true on the frame the key is released.
| Name | Type |
|---|---|
| key | string |
booleantrue if the key was released this frame.
local pressed = Input.GetDoubleKeyDown(keyA, keyB)Returns true when a specific key combination is first pressed.
| Name | Type |
|---|---|
| keyA | string |
| keyB | string |
booleantrue if both keys are triggered as a combined input.
local held = Input.GetDoubleKey(keyA, keyB)Returns true while both keys are held.
| Name | Type |
|---|---|
| keyA | string |
| keyB | string |
booleantrue if both keys are currently held.
local pressed = Input.GetMouseButtonDown(button)Triggered when a mouse button is first pressed.
| Name | Type |
|---|---|
| button | number |
booleanlocal held = Input.GetMouseButton(button)Returns true while the mouse button is held.
| Name | Type |
|---|---|
| button | number |
booleanlocal released = Input.GetMouseButtonUp(button)Triggered when a mouse button is released.
| Name | Type |
|---|---|
| button | number |
booleanlocal pos = Input.GetMousePosition()Returns the current mouse position.
Vector2Keys are passed as strings:
"A" "B" "C" ... "Z"
"0" "1" "2" ... "9"
"Space"
"Enter"
"Escape"
"Tab"
"Backspace"
"Left"
"Right"
"Up"
"Down"
"LShift" "RShift"
"LCtrl" "RCtrl"
"LAlt" "RAlt"
Input.MouseLeft
Input.MouseMiddle
Input.MouseRightif Input.GetKeyDown("W") then
print("Move forward")
end
if Input.GetMouseButton(Input.MouseLeft) then
print("Shooting")
end
local mousePos = Input.GetMousePosition()