Skip to Content

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.

FunctionReturnsDescription
input.is_key_down(vk)booleanWhether the key is held.
input.is_key_pressed(vk)booleanWhether the key was pressed this frame; excludes auto-repeat.
input.is_key_released(vk)booleanWhether the key was released this frame.
input.is_mouse_down(button)booleanWhether the mouse button is held.
input.is_mouse_pressed(button)booleanWhether the mouse button was pressed this frame.
input.mouse_position()vector2dCursor position in window pixels.
input.mouse_delta()vector2dMovement since the previous frame.
input.wheel()number, numberVertical and horizontal wheel movement in notches; positive means forward and right.

Mouse-button arguments and virtual-key codes are different:

Buttonbutton argumentvk code
Left11
Right22
Middle34
Back45
Forward56

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:

ModifierLeftRight
Shift0x100xA1
Ctrl0x110xA3
Alt0x120xA5

When a key has two tracked codes, key callbacks report the lower one, as shown above.