Functions
Return Type |
Name |
Description |
input_pad_state |
input.pad(number key) |
Returns input_pad_state for a given controller key |
input_keyboard_state |
input.key(number vk) |
Returns input_keyboard_state for a given virtual key |
input_mouse_state |
input.mouse(number key) |
Returns input_mouse_state for a given mouse key |
input_keyboard_state |
input.last_key() |
Returns input_keyboard_state for the last key pressed |
vec2 |
input.mouse_position() |
The position of the mouse cursor |
bool |
input.is_mouse_in_bounds(vec2 xy, vec2 wh) |
Whether the mouse cursor is within a bounds |
nil |
input.cursor(bool toggled) |
Sets the cursor visibility |
Types
Property |
Name |
Description |
bool |
pressed |
Whether the key is pressed |
bool |
just_pressed |
Whether the key was just pressed |
bool |
just_released |
Whether the key was just released |
Property |
Name |
Description |
bool |
double_clicked |
Whether the key just double pressed |
bool |
pressed |
Whether the key is held down |
bool |
just_pressed |
Whether the key was just pressed |
bool |
just_released |
Whether the key was just released |
string |
name |
Name of the key |
Property |
Name |
Description |
bool |
pressed |
Whether the key is held down |
bool |
just_pressed |
Whether the key was just pressed |
bool |
just_released |
Whether the key was just released |
string |
name |
Name of the key |
Examples
-- Getting the state of the 'W' key
local w_key = input.key(0x57)
print('W just pressed: ', w_key.just_pressed)
-- Getting the state of the left mouse button
local left_mouse = input.mouse(0x01)
print('Left mouse being held: ', left_mouse.pressed)
-- Getting the position of the mouse
local mouse_pos = input.mouse_position()
print('Mouse position: ', mouse_pos)
-- Getting the state of the controller key INPUT_ATTACK
local input_attack = input.pad(0x18)
print('Attacking: ', input_attack.pressed)