Input

Entityceramic.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

activeGamepads: ReadOnlyArray<Int>

List of currently connected gamepad IDs. Updated automatically when gamepads are connected or disconnected.


keyPressed(keyCode: KeyCode): Bool

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

keyJustPressed(keyCode: KeyCode): Bool

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

keyJustReleased(keyCode: KeyCode): Bool

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

scanPressed(scanCode: ScanCode): Bool

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

scanJustPressed(scanCode: ScanCode): Bool

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

scanJustReleased(scanCode: ScanCode): Bool

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

gamepadPressed(gamepadId: Int, button: GamepadButton): Bool

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

gamepadJustPressed(gamepadId: Int, button: GamepadButton): Bool

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

gamepadJustReleased(gamepadId: Int, button: GamepadButton): Bool

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

gamepadAxisValue(gamepadId: Int, axis: GamepadAxis): Float

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)

startGamepadRumble(gamepadId: Int, duration: Float, lowFrequency: Float, highFrequency: Float): Void

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

gamepadName(gamepadId: Int): String

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


pressedScanCodes: IntIntMap

pressedKeyCodes: IntIntMap

pressedGamepadButtons: IntIntMap

gamepadAxisValues: IntFloatMap

gamepadGyroDeltas: IntMap<Array<Float>>

gamepadGyroKeys: Array<Int>

gamepadNames: IntMap<String>

emitKeyDown(key: Key): Void

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

emitKeyUp(key: Key): Void

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

emitGamepadAxis(gamepadId: Int, axis: GamepadAxis, value: Float): Void

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)

emitGamepadDown(gamepadId: Int, button: GamepadButton): Void

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

emitGamepadUp(gamepadId: Int, button: GamepadButton): Void

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

emitGamepadGyro(gamepadId: Int, dx: Float, dy: Float, dz: Float): Void

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)

emitGamepadEnable(gamepadId: Int, name: String): Void

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

resetDeltas(): Void

willEmitKeyDown(key: Key): Void
Name Type
key Key

willEmitKeyUp(key: Key): Void
Name Type
key Key

willEmitGamepadEnable(gamepadId: Int, name: String): Void
Name Type
gamepadId Int
name String

willEmitGamepadDisable(gamepadId: Int): Void
Name Type
gamepadId Int

willEmitGamepadDown(gamepadId: Int, button: GamepadButton): Void
Name Type
gamepadId Int
button GamepadButton

willEmitGamepadUp(gamepadId: Int, button: GamepadButton): Void
Name Type
gamepadId Int
button GamepadButton

willEmitGamepadGyro(gamepadId: Int, dx: Float, dy: Float, dz: Float): Void
Name Type
gamepadId Int
dx Float
dy Float
dz Float

willEmitGamepadAxis(gamepadId: Int, axis: GamepadAxis, value: Float): Void
Name Type
gamepadId Int
axis GamepadAxis
value Float

new(): Void

Private constructor. Input is managed as a singleton through App.


elements
canEmitKeyDown(owner: Entity): Bool
Name Type
owner Entity
Returns
Bool

elements
canEmitKeyUp(owner: Entity): Bool
Name Type
owner Entity
Returns
Bool

elements
canEmitGamepadDown(owner: Entity): Bool
Name Type
owner Entity
Returns
Bool

elements
canEmitGamepadUp(owner: Entity): Bool
Name Type
owner Entity
Returns
Bool

Metadata

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