input
Keyboard and mouse state per rendered frame: key and button checks, cursor position, delta, wheel and virtual-key codes.
Keyboard and mouse state as observed by the menu. Press and release transitions apply to the current rendered frame, not to game ticks.
| Function | Returns | Description |
|---|---|---|
input.is_key_down(vk) | boolean | Whether the key is held. |
input.is_key_pressed(vk) | boolean | Whether the key was pressed this frame; excludes auto-repeat. |
input.is_key_released(vk) | boolean | Whether the key was released this frame. |
input.is_mouse_down(button) | boolean | Whether the mouse button is held. |
input.is_mouse_pressed(button) | boolean | Whether the mouse button was pressed this frame. |
input.mouse_position() | vector2d | Cursor position in window pixels. |
input.mouse_delta() | vector2d | Movement since the previous frame. |
input.wheel() | number, number | Vertical and horizontal wheel movement in notches; positive means forward and right. |
Mouse-button arguments and virtual-key codes are different:
| Button | button argument | vk code |
|---|---|---|
| Left | 1 | 1 |
| Right | 2 | 2 |
| Middle | 3 | 4 |
| Back | 4 | 5 |
| Forward | 5 | 6 |
There is no mouse-release function. Use input.is_key_released(vk) with the corresponding mouse virtual-key code.
vk uses Windows virtual-key codes: 0x41 is A and 0x70 is F1. Unsupported keys always return false: F13 and above, media keys, keypad Enter and the ISO <> key. A non-number argument is read as 0 and returns false without raising.
For modifier keys, use these codes:
| Modifier | Left | Right |
|---|---|---|
| Shift | 0x10 | 0xA1 |
| Ctrl | 0x11 | 0xA3 |
| Alt | 0x12 | 0xA5 |
When a key has two tracked codes, key callbacks report the lower one, as shown above.
