Input¶
The Input class provides access to the keyboard, mouse, gamepads, and the
clipboard.
Synopsis¶
Static Methods¶
Mouse¶
Input.mouse([window])Input.mouse_down(button[, window])Input.mouse_global_x()Input.mouse_global_y()Input.mouse_pressed(button[, window])Input.mouse_released(button[, window])Input.mouse_wheel_x([window])Input.mouse_wheel_y([window])Input.mouse_x([window])Input.mouse_y([window])
Keyboard¶
Input.chars([window])Input.key_down(key[, window])Input.key_pressed(key[, window])Input.key_released(key[, window])Input.key_repeat(key[, window])Input.key_to_keychar(key)Input.keychar_to_key(keyChar)
Gamepad & Joystick¶
Input.gamepad_add_mapping(mapping)Input.gamepad_add_mappings_from_file([path])Input.gamepad_axis(axis[, slot])Input.gamepad_axis_count([slot])Input.gamepad_battery_percent([slot])Input.gamepad_battery_state([slot])Input.gamepad_button_count([slot])Input.gamepad_button_down(button[, slot])Input.gamepad_button_label(button[, slot])Input.gamepad_button_pressed(button[, slot])Input.gamepad_button_released(button[, slot])Input.gamepad_connection_state([slot])Input.gamepad_has_axis(axis[, slot])Input.gamepad_has_button(button[, slot])Input.gamepad_has_sensor(sensor[, slot])Input.gamepad_led([color[, slot]])Input.gamepad_mapping([slot])Input.gamepad_name([index])Input.gamepad_product_id([slot])Input.gamepad_rumble([low[, high[, duration[, slot]]]])Input.gamepad_rumble_triggers([left[, right[, duration[, slot]]]])Input.gamepad_sensor(sensorType[, slot])Input.gamepad_serial([slot])Input.gamepad_set_sensor_enabled(sensorType, enabled[, slot])Input.gamepad_touchpad_count([slot])Input.gamepad_touchpad_down(touchpad, finger[, slot])Input.gamepad_touchpad_pressure(touchpad, finger[, slot])Input.gamepad_touchpad_x(touchpad, finger[, slot])Input.gamepad_touchpad_y(touchpad, finger[, slot])Input.gamepad_trackball_count([slot])Input.gamepad_trackball_x(trackball[, slot])Input.gamepad_trackball_y(trackball[, slot])Input.gamepad_type([slot])Input.gamepad_flush([slot])Input.gamepad_reassign_slot([index[, slot]])Input.joystick_axis(axisIndex)Input.joystick_button(buttonIndex)
Cursor¶
Clipboard¶
Static Members¶
Static Methods¶
Mouse Methods¶
Input.mouse([window])¶
Returns a table containing the mouse coordinates, wheel deltas, and related data.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
table: A table containing mouse values
Mouse Table¶
| Field | Type | Description |
|---|---|---|
x |
int |
Mouse X position on given window. |
y |
int |
Mouse Y position on given window. |
global_x |
int |
Mouse X position in screen space. |
global_y |
int |
Mouse Y position in screen space. |
wheel_x |
float |
Horizontal mouse wheel scroll delta. |
wheel_y |
float |
Vertical mouse wheel scroll delta. |
buttons |
table |
Table of mouse button status tables with pressed, released and down fields. |
Input.mouse_down(button[, window])¶
Reports whether a specific mouse button is currently held down.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
button |
int |
Yes | The mouse button identifier (e.g., Input.MouseLeft). |
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
bool:trueif the button is held down,falseotherwise.
Input.mouse_global_x()¶
Returns the current global mouse X position in screen space.
- Returns:
int: Global screen X coordinate.
Input.mouse_global_y()¶
Returns the current global mouse Y position in screen space.
- Returns:
int: Global screen Y coordinate.
Input.mouse_pressed(button[, window])¶
Reports whether a mouse button was pressed during the current frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
button |
int |
Yes | The mouse button identifier. |
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
bool:trueif pressed this frame,falseotherwise.
Input.mouse_released(button[, window])¶
Reports whether a mouse button was released during the current frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
button |
int |
Yes | The mouse button identifier. |
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
bool:trueif released this frame,falseotherwise.
Input.mouse_wheel_x([window])¶
Returns the horizontal mouse wheel delta for the current frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
float: Horizontal scroll wheel displacement.
Input.mouse_wheel_y([window])¶
Returns the vertical mouse wheel delta for the current frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
float: Vertical scroll wheel displacement.
Input.mouse_x([window])¶
Returns the current mouse X position on given window.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
int: Local window X coordinate.
Input.mouse_y([window])¶
Returns the current mouse Y position on given window.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
int: Local window Y coordinate.
Keyboard Methods¶
Input.chars([window])¶
Returns any text characters entered or typed during the current frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
string: A UTF-8 sequence of typed input characters.
Input.key_down(key[, window])¶
Reports whether a specific keyboard key is currently being held down.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
int |
Yes | Key scancode constant identifier (e.g., Input.KeyA). |
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
bool:trueif held down,falseotherwise.
Input.key_pressed(key[, window])¶
Reports whether a specific key was freshly pressed during the current frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
int |
Yes | Key scancode identifier. |
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
bool:trueif pressed this frame,falseotherwise.
Input.key_released(key[, window])¶
Reports whether a specific key was released during the current frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
int |
Yes | Key scancode identifier. |
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
bool:trueif released this frame,falseotherwise.
Input.key_repeat(key[, window])¶
Reports whether a system key-repeat flag is active for the given held key on this frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
int |
Yes | Key scancode identifier. |
window |
Window | int |
No | Target window context. Defaults to the currently focused window. |
- Returns:
bool:trueif repeating this frame,falseotherwise.
Input.key_to_keychar(key)¶
Translates a Key constant to a literal layout character string (e.g., "z",
"m", "5") based on the active operating system keyboard layout.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
key |
int |
Yes | The Input.Key* constant code you wish to evaluate. |
- Returns:
string: The string character printed on the matching physical keycap.
Input.keychar_to_key(keyChar)¶
Translates a keyboard layout string literal (e.g., "z", "m", "5",
"escape") into its corresponding Key constant based on the active operating
system keyboard layout.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
keyChar |
string |
Yes | The alphanumeric character printed on the physical keycap, or a specific key name identifier (e.g., "escape", "space"). |
- Returns:
int: A matchingInput.Key*constant, orInput.KeyUnknownif no match is found.
Gamepad Methods¶
Input.gamepad_add_mapping(mapping)¶
Adds a mapping for a gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
mapping |
string |
Yes | A mapping string to map a gamepad. |
Mapping string
The mapping string follows the standard
SDL Gamepad Mapping
format (identical to the community
gamecontrollerdb.txt
format).
It is a comma-separated string containing the controller's 32-character GUID, a descriptive name, and a list of hardware element bindings.
Format Structure:
- GUID: A 32-character hexadecimal string identifying the specific hardware device type (encoding its USB Vendor ID, Product ID, and version).
- Name: A user-friendly name for the device (e.g.,
Prizee USB Joystick). - Bindings: Key-value pairs matching standard gamepad inputs to hardware
elements (
bfor buttons,afor axes,hfor hats/D-Pads).
How to find or compute a GUID:
Since GUIDs are derived from raw USB/Bluetooth hardware IDs, you generally do not compute them by hand. Instead, you can obtain them via:
- Community Databases: Look up your controller in the community-maintained SDL_GameControllerDB to find its exact GUID and pre-configured mapping string.
- Mapping Tools: Use standalone utilities like the ones listed here to physically press buttons on your unrecognized controller. The tools will automatically compute the correct GUID and generate the exact mapping string needed for this function.
Example:
Input.gamepad_add_mappings_from_file([path])¶
Adds multiple gamepad mappings at once by loading them from a specified text file.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path |
string |
No | The file path to load mappings from. Defaults to "res://gamecontrollerdb.txt". |
Community Database
This function is specifically designed to work with the community-maintained SDL_GameControllerDB.
Download the latest gamecontrollerdb.txt file, place it in
your project's root directory, and call this function during initialization
to automatically support a lot of standard and third-party controllers.
Input.gamepad_axis(axis[, slot])¶
Returns the displacement analog value for a given gamepad joystick axis.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
axis |
int |
Yes | Gamepad axis constant identifier (e.g., Input.GamepadAxisLeftX). |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
float: Axis displacement reading.
Input.gamepad_axis_count([slot])¶
Get axis count for a gamepad at given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: Axis count of the gamepad.
Input.gamepad_battery_percent([slot])¶
Get percentage of battery life left for a gamepad at given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: The percentage of battery life left ranging from0to100.
Input.gamepad_battery_state([slot])¶
Get battery state for a gamepad at given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: The battery state ranging fromGamepadBatteryUnknowntoGamepadBatteryCharged. Cf Gamepad battery constants.
Battery state
You should never take a battery status as absolute truth. Batteries (especially failing batteries) are delicate hardware, and the values reported here are best estimates based on what that hardware reports.
It's not uncommon for older batteries to lose stored power much faster than it reports, or completely drain when reporting it has 20 percent left, etc.
Input.gamepad_button_count([slot])¶
Get button count for a gamepad at given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: Button count of the gamepad.
Input.gamepad_button_down(button[, slot])¶
Reports whether a button is currently held down on a specific gamepad controller.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
button |
int |
Yes | Gamepad button constant identifier (e.g., Input.GamepadDPadUp). |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif held down,falseotherwise.
Input.gamepad_button_pressed(button[, slot])¶
Reports whether a gamepad button was freshly pressed during the current frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
button |
int |
Yes | Gamepad button constant identifier. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif pressed this frame,falseotherwise.
Input.gamepad_button_released(button[, slot])¶
Reports whether a gamepad button was released during the current frame.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
button |
int |
Yes | Gamepad button constant identifier. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif released this frame,falseotherwise.
Input.gamepad_button_label(button[, slot])¶
Get the label of given button for a gamepad at given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
button |
int |
Yes | Gamepad button constant identifier. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: The hardware display label constant matching the physical button configuration. Cf Gamepad button label constants.
Input.gamepad_connection_state([slot])¶
Get connection state for a gamepad at given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: The connection state. Cf Gamepad connection constants.
Input.gamepad_has_axis(axis[, slot])¶
Checks the axis availability for a given gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
axis |
int |
Yes | Gamepad axis constant identifier (e.g., Input.GamepadAxisLeftX). |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif given axis is available,falseotherwise.
Input.gamepad_has_button(button[, slot])¶
Checks the button availability for a given gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
button |
int |
Yes | Gamepad button constant identifier (e.g., Input.GamepadButtonSouth). |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif given button is available,falseotherwise.
Input.gamepad_has_sensor(sensor[, slot])¶
Checks the sensor availability for a given gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
sensor |
int |
Yes | Gamepad sensor constant identifier (e.g., Input.GamepadSensorAccelerometer). |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif given sensor is available,falseotherwise.
Input.gamepad_led([color[, slot]])¶
Set gamepad LED color.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
color |
Color | string | int | array | table |
No | LED color. See Color Formats. Defaults to Color.White. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif effect was successfully triggered.falseotherwise.
Input.gamepad_mapping([slot])¶
Returns the gamepad mapping of given gamepad if gamepad is mapped.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
string: The gamepad mapping if gamepad is mapped.
Input.gamepad_name([index])¶
Returns the hardware name of given gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
index |
int |
No | Gamepad hardware index identifier. Default: 0. |
- Returns:
string: The name of the gamepad hardware.
Input.gamepad_product_id([slot])¶
Returns the product ID of given gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: The gamepad's product ID.
Input.gamepad_rumble([low[, high[, duration[, slot]]]])¶
Plays a haptic rumble effect on the gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
low |
int |
No | Intensity of the low frequency (left) rumble motor. Defaults to 0. |
high |
int |
No | Intensity of the high frequency (right) rumble motor. Defaults to 0. |
duration |
int |
No | Duration of the rumble effect, in milliseconds. Defaults to 0. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif effect was successfully triggered.falseotherwise.
Input.gamepad_rumble_triggers([left[, right[, duration[, slot]]]])¶
Plays a haptic rumble effect on the gamepad's triggers.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
left |
int |
No | Left trigger motor intensity. Defaults to 0. |
right |
int |
No | Right trigger motor intensity. Defaults to 0. |
duration |
int |
No | Duration of the rumble effect, in milliseconds. Defaults to 0. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif effect was successfully triggered.falseotherwise.
Input.gamepad_sensor(sensorType[, slot])¶
Get sensor status for a gamepad at given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
sensorType |
int |
Yes | Sensor type to query. Cf Gamepad sensor constants. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
array: Array of 3 float values representing the sensor status.
Input.gamepad_serial([slot])¶
Returns the serial of given gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
string: The gamepad's serial.
Input.gamepad_set_sensor_enabled(sensorType, enabled[, slot])¶
Enables or disables a specific sensor status data stream for a gamepad at the given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
sensorType |
int |
Yes | Sensor type to configure. Cf Gamepad sensor constants. |
enabled |
bool |
Yes | true to enable the sensor data stream, false to disable it. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif the sensor state was successfully altered,falseotherwise.
Input.gamepad_touchpad_count([slot])¶
Get touchpad count for a gamepad at given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: Touchpad count of the gamepad.
Input.gamepad_touchpad_down(touchpad, finger[, slot])¶
Reports whether a specific finger is touching a touchpad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
touchpad |
int |
Yes | Touchpad index. |
finger |
int |
Yes | Finger index. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif given finger is touching the touchpad.
Input.gamepad_touchpad_pressure(touchpad, finger[, slot])¶
Returns the pressure (0..1) of a finger on a touchpad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
touchpad |
int |
Yes | Touchpad index. |
finger |
int |
Yes | Finger index. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
float: The pressure of a finger on a touchpad.
Input.gamepad_touchpad_x(touchpad, finger[, slot])¶
Returns the normalized X (0..1) position of a finger on a touchpad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
touchpad |
int |
Yes | Touchpad index. |
finger |
int |
Yes | Finger index. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
float: The X position of a finger on a touchpad.
Input.gamepad_touchpad_y(touchpad, finger[, slot])¶
Returns the normalized Y (0..1) position of a finger on a touchpad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
touchpad |
int |
Yes | Touchpad index. |
finger |
int |
Yes | Finger index. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
float: The Y position of a finger on a touchpad.
Input.gamepad_trackball_count([slot])¶
Get trackball count for a gamepad at given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: Trackball count of the gamepad.
Input.gamepad_trackball_x(trackball[, slot])¶
Returns the relative horizontal motion (delta) of a trackball since the last frame update.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
trackball |
int |
Yes | Trackball index. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
float: The signed relative horizontal displacement. Positive values indicate rightward rolling motion, while negative values indicate leftward rolling motion.
Input.gamepad_trackball_y(trackball[, slot])¶
Returns the relative vertical motion (delta) of a trackball since the last frame update.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
trackball |
int |
Yes | Trackball index. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
float: The signed relative vertical displacement. Positive values indicate downward rolling motion, while negative values indicate upward rolling motion.
Input.gamepad_type([slot])¶
Returns the gamepad type of the given gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: The gamepad type of given gamepad. Cf Gamepad type constants.
Input.gamepad_vendor_id([slot])¶
Returns the vendor ID of given gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
int: The gamepad's vendor ID.
Input.gamepad_count()¶
Returns the total count of currently connected gamepads.
- Returns:
int: Number of active gamepads.
Input.gamepad_flush([slot])¶
Wipes input mapping for a given logical slot.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
Input.gamepad_reassign_slot([index[, slot]])¶
Reassign a gamepad to another slot. Use -1 to unbind a gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
index |
int |
No | Gamepad hardware index identifier. Default: 0. |
slot |
int |
No | Gamepad slot index identifier. Default: 0. |
- Returns:
bool:trueif reassignment succeeded,falseotherwise.
Input.gamepad_slot([index])¶
Returns the logical slot of given gamepad.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
index |
int |
No | Gamepad hardware index identifier. Default: 0. |
- Returns:
int: Active slot or-1if unassigned.
Input.is_joystick([slot])¶
Checks whether the input device connected to the specified slot is acting as a raw, generic joystick rather than a mapped standard gamepad layout.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
slot |
int |
No | Gamepad hardware index identifier. Default: 0. |
- Returns:
bool:trueif the device is recognized as a raw joystick,falseif it maps to a standard gamepad profile.
Input.joystick_axis(axisIndex)¶
Calculates a unique, non-colliding axis identifier for a raw joystick axis.
Use this to safely query axes on devices where Input.is_joystick() returns
true.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
axisIndex |
int |
Yes | The raw 0-indexed axis number provided by the joystick hardware. |
- Returns:
int: A distinct axis ID that safely bypasses standard gamepad axis range.
Input.joystick_button(buttonIndex)¶
Calculates a unique, non-colliding button identifier for a raw joystick button.
Use this to safely query buttons on devices where Input.is_joystick() returns
true.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
buttonIndex |
int |
Yes | Raw joystick button to translate to a gamepad button. |
- Returns:
int: A distinct button ID that safely bypasses standard gamepad button range.
Cursor Methods¶
Input.cursor_visible()¶
Reports whether the system pointer cursor is currently visible over application windows.
- Returns:
bool:trueif visible,falseotherwise.
Input.set_cursor(path)¶
Changes the look of the system mouse cursor using an image path or a standard system cursor constant.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
path |
string |
Yes | Image path or system cursor string constant. |
Input.set_cursor_visible(visible)¶
Configures the screen mouse cursor display visibility state.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
visible |
bool |
Yes | true to make it visible, false to hide it. |
Clipboard Methods¶
Input.clipboard([text])¶
Interacts with the system clipboard to either copy text content or read the text it currently holds.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
string |
No | Text content to copy into the clipboard system. If omitted, performs a read query instead. |
- Returns:
string|null: The string text contained inside the clipboard if called without arguments; otherwise returnsnull.
Static Members¶
Mouse Constants¶
| Constant | Type | Description |
|---|---|---|
Input.MouseLeft |
int |
Left mouse button. |
Input.MouseMiddle |
int |
Middle mouse button. |
Input.MouseRight |
int |
Right mouse button. |
Input.MouseX1 |
int |
Extended X1 mouse side button. |
Input.MouseX2 |
int |
Extended X2 mouse side button. |
Cursor Constants¶
| Constant | Type | Description |
|---|---|---|
Input.CursorDefault |
string |
Standard system arrow pointer. |
Input.CursorText |
string |
Text insertion I-beam pointer. |
Input.CursorWait |
string |
Hourglass or system busy wait cursor. |
Input.CursorCrosshair |
string |
Precision crosshair selector cursor. |
Input.CursorProgress |
string |
Background task progress pointer. |
Input.CursorMove |
string |
Omnidirectional generic move cursor. |
Input.CursorNotAllowed |
string |
Action forbidden standard symbol cursor. |
Input.CursorPointer |
string |
Context link selection hand pointer. |
Input.CursorResizeNorth |
string |
Upwards edge resize arrow. |
Input.CursorResizeNorthEast |
string |
Diagonal Upwards/Rightwards edge resize arrow. |
Input.CursorResizeEast |
string |
Rightwards edge resize arrow. |
Input.CursorResizeSouthEast |
string |
Diagonal Downwards/Rightwards edge resize arrow. |
Input.CursorResizeSouth |
string |
Downwards edge resize arrow. |
Input.CursorResizeSouthWest |
string |
Diagonal Downwards/Leftwards edge resize arrow. |
Input.CursorResizeWest |
string |
Leftwards edge resize arrow. |
Input.CursorResizeNorthWest |
string |
Diagonal Upwards/Leftwards edge resize arrow. |
Input.CursorResizeNorthSouth |
string |
Vertical Upwards/Downwards arrow. |
Input.CursorResizeEastWest |
string |
Horizontal Leftwards/Rightwards arrow. |
Input.CursorResizeNorthWestSouthEast |
string |
|
Input.CursorResizeNorthEastSouthWest |
string |
Gamepad Constants¶
Gamepad Axis Constants¶
| Constant | Type | Description |
|---|---|---|
Input.GamepadAxisLeftX |
int |
Left stick horizontal axis. |
Input.GamepadAxisLeftY |
int |
Left stick vertical axis. |
Input.GamepadAxisRightX |
int |
Right stick horizontal axis. |
Input.GamepadAxisRightY |
int |
Right stick vertical axis. |
Input.GamepadAxisLeftTrigger |
int |
Left trigger axis. |
Input.GamepadAxisRightTrigger |
int |
Right trigger axis. |
Input.GamepadAxisCount |
int |
The count of supported axes. |
Gamepad Battery Constants¶
| Constant | Type | Description |
|---|---|---|
Input.GamepadBatteryError |
int |
Error while getting battery status. |
Input.GamepadBatteryUnknown |
int |
Unknown battery status. |
Input.GamepadBatteryOnBattery |
int |
Not plugged in, running on the battery. |
Input.GamepadBatteryNoBattery |
int |
Plugged in, no battery available. |
Input.GamepadBatteryCharging |
int |
Plugged in, charging battery. |
Input.GamepadBatteryCharged |
int |
Plugged in, battery charged. |
Gamepad Button Constants¶
| Constant | Type | Description |
|---|---|---|
Input.GamepadButtonBack |
int |
Back button. |
Input.GamepadButtonDPadDown |
int |
Directional Pad down button. |
Input.GamepadButtonDPadLeft |
int |
Directional Pad left button. |
Input.GamepadButtonDPadRight |
int |
Directional Pad right button. |
Input.GamepadButtonDPadUp |
int |
Directional Pad up button. |
Input.GamepadButtonEast |
int |
East button. |
Input.GamepadButtonGuide |
int |
Guide button. |
Input.GamepadButtonLeftPaddle1 |
int |
Upper or primary paddle, under left hand. |
Input.GamepadButtonLeftPaddle2 |
int |
Lower or secondary paddle, under left hand. |
Input.GamepadButtonLeftShoulder |
int |
Left bumper control shoulder. |
Input.GamepadButtonLeftStick |
int |
Left thumbstick analog button. |
Input.GamepadButtonMisc1 |
int |
Additional button. |
Input.GamepadButtonMisc2 |
int |
Additional button. |
Input.GamepadButtonMisc3 |
int |
Additional button. |
Input.GamepadButtonMisc4 |
int |
Additional button. |
Input.GamepadButtonMisc5 |
int |
Additional button. |
Input.GamepadButtonMisc6 |
int |
Additional button. |
Input.GamepadButtonNorth |
int |
North button. |
Input.GamepadButtonRightPaddle1 |
int |
Upper or primary paddle, under right hand. |
Input.GamepadButtonRightPaddle2 |
int |
Lower or secondary paddle, under right hand. |
Input.GamepadButtonRightShoulder |
int |
Right bumper control shoulder. |
Input.GamepadButtonRightStick |
int |
Right thumbstick analog button. |
Input.GamepadButtonSouth |
int |
South button. |
Input.GamepadButtonStart |
int |
Start button. |
Input.GamepadButtonTouchpad |
int |
Touchpad button. |
Input.GamepadButtonWest |
int |
West button. |
Input.GamepadButtonCount |
int |
The count of supported buttons. |
Input.GamepadButtonL1 |
int |
Alias for Input.GamepadButtonLeftShoulder. |
Input.GamepadButtonLB |
int |
Alias for Input.GamepadButtonLeftShoulder. |
Input.GamepadButtonR1 |
int |
Alias for Input.GamepadButtonRightShoulder. |
Input.GamepadButtonRB |
int |
Alias for Input.GamepadButtonRightShoulder. |
Input.GamepadButtonXBoxA |
int |
Alias for Input.GamepadButtonSouth. |
Input.GamepadButtonXBoxB |
int |
Alias for Input.GamepadButtonEast. |
Input.GamepadButtonXBoxX |
int |
Alias for Input.GamepadButtonWest. |
Input.GamepadButtonXBoxY |
int |
Alias for Input.GamepadButtonNorth. |
Input.GamepadButtonPSCross |
int |
Alias for Input.GamepadButtonSouth. |
Input.GamepadButtonPSCircle |
int |
Alias for Input.GamepadButtonEast. |
Input.GamepadButtonPSSquare |
int |
Alias for Input.GamepadButtonWest. |
Input.GamepadButtonPSTriangle |
int |
Alias for Input.GamepadButtonNorth. |
Diamond pattern
For controllers that use a diamond pattern for the face buttons,
the Input.GamepadButtonSouth / Input.GamepadButtonEast /
Input.GamepadButtonWest / Input.GamepadButtonNorth buttons correspond to
the locations in the diamond pattern.
| Console Controller | South | East | North | West |
|---|---|---|---|---|
| PlayStation | Cross | Circle | Triangle | Square |
| Nintendo (Except GameCube) | B | A | X | Y |
| Nintendo GameCube | A | X | Y | B |
| XBox | A | B | Y | X |
Without diamond
For controllers that don't use a diamond pattern for the face buttons, the
Input.GamepadButtonSouth / Input.GamepadButtonEast /
Input.GamepadButtonWest / Input.GamepadButtonNorth buttons indicate the
buttons labeled A, B, C, D, or 1, 2, 3, 4, or for
controllers that aren't labeled, they are the primary, secondary, etc.
buttons.
Gamepad Button Label Constants¶
| Constant | Type | Description |
|---|---|---|
Input.GamepadButtonLabelUnknown |
int |
Unknown button label. |
Input.GamepadButtonLabelA |
int |
A button label. |
Input.GamepadButtonLabelB |
int |
B button label. |
Input.GamepadButtonLabelX |
int |
X button label. |
Input.GamepadButtonLabelY |
int |
Y button label. |
Input.GamepadButtonLabelCross |
int |
Cross shaped button label. |
Input.GamepadButtonLabelCircle |
int |
Circle shaped button label. |
Input.GamepadButtonLabelSquare |
int |
Square shaped button label. |
Input.GamepadButtonLabelTriangle |
int |
Triangle shaped button label. |
Gamepad Connection Constants¶
| Constant | Type | Description |
|---|---|---|
Input.GamepadConnectionInvalid |
int |
Invalid connection status. |
Input.GamepadConnectionUnknown |
int |
Unknown connection status. |
Input.GamepadConnectionWired |
int |
Wired connection. |
Input.GamepadConnectionWireless |
int |
Wireless connection. |
Gamepad Sensor Constants¶
| Constant | Type | Description |
|---|---|---|
Input.GamepadSensorUnknown |
int |
Unknown sensor type. |
Input.GamepadSensorAccelerometer |
int |
Accelerometer. |
Input.GamepadSensorGyroscope |
int |
Gyroscope. |
Input.GamepadSensorAccelerometerLeft |
int |
Accelerometer for left controller. |
Input.GamepadSensorGyroscopeLeft |
int |
Gyroscope for left controller. |
Input.GamepadSensorAccelerometerRight |
int |
Accelerometer for right controller. |
Input.GamepadSensorGyroscopeRight |
int |
Gyroscope for right controller. |
Gamepad Type Constants¶
| Constant | Type | Description |
|---|---|---|
Input.GamepadTypeUnknown |
int |
|
Input.GamepadTypeStandard |
int |
|
Input.GamepadTypeXBox360 |
int |
|
Input.GamepadTypeXBoxOne |
int |
|
Input.GamepadTypePS3 |
int |
|
Input.GamepadTypePS4 |
int |
|
Input.GamepadTypePS5 |
int |
|
Input.GamepadTypeNintendoSwitchPro |
int |
|
Input.GamepadTypeNintendoSwitchJoyConLeft |
int |
|
Input.GamepadTypeNintendoSwitchJoyConRight |
int |
|
Input.GamepadTypeNintendoSwitchJoyConPair |
int |
|
Input.GamepadTypeNintendoGamecube |
int |
|
Input.GamepadTypeWheel |
int |
|
Input.GamepadTypeArcadeStick |
int |
|
Input.GamepadTypeFlightStick |
int |
|
Input.GamepadTypeDancePad |
int |
|
Input.GamepadTypeGuitar |
int |
|
Input.GamepadTypeDrumKit |
int |
|
Input.GamepadTypeArcadePad |
int |
|
Input.GamepadTypeThrottle |
int |
|
Input.GamepadTypeCount |
int |
The count of supported gamepad types. |
Gamepad Misc Constants¶
| Constant | Type | Description |
|---|---|---|
Input.GamepadSlots |
int |
Count of gamepad slots. |
Keyboard Constants¶
Basic keys¶
| Constant | Type | Description |
|---|---|---|
Input.KeyA |
int |
|
Input.KeyB |
int |
|
Input.KeyC |
int |
|
Input.KeyD |
int |
|
Input.KeyE |
int |
|
Input.KeyF |
int |
|
Input.KeyG |
int |
|
Input.KeyH |
int |
|
Input.KeyI |
int |
|
Input.KeyJ |
int |
|
Input.KeyK |
int |
|
Input.KeyL |
int |
|
Input.KeyM |
int |
|
Input.KeyN |
int |
|
Input.KeyO |
int |
|
Input.KeyP |
int |
|
Input.KeyQ |
int |
|
Input.KeyR |
int |
|
Input.KeyS |
int |
|
Input.KeyT |
int |
|
Input.KeyU |
int |
|
Input.KeyV |
int |
|
Input.KeyW |
int |
|
Input.KeyX |
int |
|
Input.KeyY |
int |
|
Input.KeyZ |
int |
|
Input.Key0 |
int |
|
Input.Key1 |
int |
|
Input.Key2 |
int |
|
Input.Key3 |
int |
|
Input.Key4 |
int |
|
Input.Key5 |
int |
|
Input.Key6 |
int |
|
Input.Key7 |
int |
|
Input.Key8 |
int |
|
Input.Key9 |
int |
|
Input.KeyReturn |
int |
|
Input.KeyEscape |
int |
|
Input.KeyBackspace |
int |
|
Input.KeyTab |
int |
|
Input.KeySpace |
int |
|
Input.KeyMinus |
int |
|
Input.KeyEquals |
int |
|
Input.KeyLeftBracket |
int |
|
Input.KeyRightBracket |
int |
|
Input.KeyBackslash |
int |
|
Input.KeyIsoBackslash |
int |
|
Input.KeyIsoHash |
int |
|
Input.KeySemicolon |
int |
|
Input.KeyQuote |
int |
|
Input.KeyGrave |
int |
|
Input.KeyComma |
int |
|
Input.KeyPeriod |
int |
|
Input.KeySlash |
int |
|
Input.KeyCapsLock |
int |
|
Input.KeyF1 |
int |
|
Input.KeyF2 |
int |
|
Input.KeyF3 |
int |
|
Input.KeyF4 |
int |
|
Input.KeyF5 |
int |
|
Input.KeyF6 |
int |
|
Input.KeyF7 |
int |
|
Input.KeyF8 |
int |
|
Input.KeyF9 |
int |
|
Input.KeyF10 |
int |
|
Input.KeyF11 |
int |
|
Input.KeyF12 |
int |
|
Input.KeyPrintScreen |
int |
|
Input.KeyScrollLock |
int |
|
Input.KeyPause |
int |
|
Input.KeyInsert |
int |
|
Input.KeyHome |
int |
|
Input.KeyPageUp |
int |
|
Input.KeyDelete |
int |
|
Input.KeyEnd |
int |
|
Input.KeyPageDown |
int |
|
Input.KeyRight |
int |
|
Input.KeyLeft |
int |
|
Input.KeyDown |
int |
|
Input.KeyUp |
int |
Keypad keys¶
| Constant | Type | Description |
|---|---|---|
Input.KeyNumLockClear |
int |
|
Input.KeyKPDivide |
int |
|
Input.KeyKPMultiply |
int |
|
Input.KeyKPMinus |
int |
|
Input.KeyKPPlus |
int |
|
Input.KeyKPEnter |
int |
|
Input.KeyKP1 |
int |
|
Input.KeyKP2 |
int |
|
Input.KeyKP3 |
int |
|
Input.KeyKP4 |
int |
|
Input.KeyKP5 |
int |
|
Input.KeyKP6 |
int |
|
Input.KeyKP7 |
int |
|
Input.KeyKP8 |
int |
|
Input.KeyKP9 |
int |
|
Input.KeyKP0 |
int |
|
Input.KeyKPPeriod |
int |
Modifiers keys¶
| Constant | Type | Description |
|---|---|---|
Input.KeyLeftControl |
int |
|
Input.KeyLeftShift |
int |
|
Input.KeyLeftAlt |
int |
|
Input.KeyLeftGUI |
int |
|
Input.KeyRightControl |
int |
|
Input.KeyRightShift |
int |
|
Input.KeyRightAlt |
int |
|
Input.KeyRightGUI |
int |
Special keys¶
| Constant | Type | Description |
|---|---|---|
Input.KeyCount |
int |
The count of supported keys. |
Examples¶
Example code is available here.
Example code for handling gamepads and joysticks is available here.