Input
Entity →
ceramic.Input (Class)
Manages all input handling for keyboard and gamepad devices.
The Input system provides:
- Keyboard input detection (key press, release, and hold states)
- Gamepad support (buttons, analog axes, gyroscope)
- Input state queries (pressed, just pressed, just released)
- Gamepad vibration/rumble control
- Integration with UI elements to prevent input conflicts
The system tracks three states for inputs:
- Just pressed: True only on the frame the input was pressed
- Pressed: True while the input is held down
- Just released: True only on the frame the input was released
Instance Members
List of currently connected gamepad IDs.
Updated automatically when gamepads are connected or disconnected.
Checks if a key is currently pressed (held down).
Returns true for every frame while the key is held.
Name |
Type |
Description |
keyCode |
KeyCode |
The key code to check |
Returns |
Description |
Bool |
True if the key is currently pressed |
Checks if a key was just pressed this frame.
Returns true only on the frame the key was initially pressed.
Name |
Type |
Description |
keyCode |
KeyCode |
The key code to check |
Returns |
Description |
Bool |
True if the key was just pressed this frame |
Checks if a key was just released this frame.
Returns true only on the frame the key was released.
Name |
Type |
Description |
keyCode |
KeyCode |
The key code to check |
Returns |
Description |
Bool |
True if the key was just released this frame |
Checks if a key is currently pressed using scan code.
Scan codes represent physical key positions and are layout-independent.
Name |
Type |
Description |
scanCode |
ScanCode |
The scan code to check |
Returns |
Description |
Bool |
True if the key is currently pressed |
Checks if a key was just pressed this frame using scan code.
Name |
Type |
Description |
scanCode |
ScanCode |
The scan code to check |
Returns |
Description |
Bool |
True if the key was just pressed this frame |
Checks if a key was just released this frame using scan code.
Name |
Type |
Description |
scanCode |
ScanCode |
The scan code to check |
Returns |
Description |
Bool |
True if the key was just released this frame |
Checks if a gamepad button is currently pressed.
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad to check |
button |
GamepadButton |
The button to check |
Returns |
Description |
Bool |
True if the button is currently pressed |
Checks if a gamepad button was just pressed this frame.
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad to check |
button |
GamepadButton |
The button to check |
Returns |
Description |
Bool |
True if the button was just pressed this frame |
Checks if a gamepad button was just released this frame.
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad to check |
button |
GamepadButton |
The button to check |
Returns |
Description |
Bool |
True if the button was just released this frame |
Gets the current value of a gamepad analog axis.
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad to check |
axis |
GamepadAxis |
The axis to check (e.g., LEFT_X, RIGHT_TRIGGER) |
Returns |
Description |
Float |
The axis value (-1.0 to 1.0 for sticks, 0.0 to 1.0 for triggers) |
gamepadGyroDeltaX(gamepadId: Int): Float
Gets the accumulated gyroscope delta for the X axis since last frame.
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad |
Returns |
Description |
Float |
Angular velocity around X axis (radians/second) |
gamepadGyroDeltaY(gamepadId: Int): Float
Gets the accumulated gyroscope delta for the Y axis since last frame.
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad |
Returns |
Description |
Float |
Angular velocity around Y axis (radians/second) |
gamepadGyroDeltaZ(gamepadId: Int): Float
Gets the accumulated gyroscope delta for the Z axis since last frame.
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad |
Returns |
Description |
Float |
Angular velocity around Z axis (radians/second) |
Starts a controller rumble.
Name |
Type |
Description |
gamepadId |
Int |
The id of the gamepad getting rumble |
duration |
Float |
The duration, in seconds |
lowFrequency |
Float |
Low frequency: value between 0 and 1 |
highFrequency |
Float |
High frequency: value between 0 and 1 |
stopGamepadRumble(gamepadId: Int): Void
Stops any active rumble on the specified gamepad.
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad |
Gets the name/description of a connected gamepad.
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad |
Returns |
Description |
String |
The gamepad name, or null if not connected |
Private Members
GAMEPAD_STORAGE_SIZE: Int
Internal value to store gamepad state
Triggered when a key from the keyboard is being pressed.
This event fires repeatedly while a key is held down.
@event keyDown
Name |
Type |
Description |
key |
Key |
The key being pressed, containing both keyCode and scanCode |
Triggered when a key from the keyboard is being released.
@event keyUp
Name |
Type |
Description |
key |
Key |
The key being released, containing both keyCode and scanCode |
Triggered when a gamepad analog axis value changes.
@event gamepadAxis
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad (0-based index) |
axis |
GamepadAxis |
The axis that changed (e.g., LEFT_X, RIGHT_TRIGGER) |
value |
Float |
The new axis value (-1.0 to 1.0 for sticks, 0.0 to 1.0 for triggers) |
Triggered when a gamepad button is pressed.
@event gamepadDown
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad (0-based index) |
button |
GamepadButton |
The button being pressed |
Triggered when a gamepad button is released.
@event gamepadUp
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad (0-based index) |
button |
GamepadButton |
The button being released |
Triggered when gamepad gyroscope data is received.
@event gamepadGyro
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad (0-based index) |
dx |
Float |
Angular velocity around X axis (radians/second) |
dy |
Float |
Angular velocity around Y axis (radians/second) |
dz |
Float |
Angular velocity around Z axis (radians/second) |
Triggered when a gamepad is connected and enabled.
@event gamepadEnable
Name |
Type |
Description |
gamepadId |
Int |
The ID assigned to the gamepad (0-based index) |
name |
String |
The name/description of the gamepad device |
emitGamepadDisable(gamepadId: Int): Void
Triggered when a gamepad is disconnected or disabled.
@event gamepadDisable
Name |
Type |
Description |
gamepadId |
Int |
The ID of the gamepad being disabled |
willEmitGamepadDisable(gamepadId: Int): Void
Private constructor. Input is managed as a singleton through App.
Name |
Parameters |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:allow |
ceramic.App |