Creates a new InputManager instance.
Polling rate for gamepad inputs (default: 60, range: 1-120)
Dead zone threshold for gamepad sticks (default: 0.1, range: 0-1)
OptionalaxesThrottleMs: numberOptional throttle for axis update events in milliseconds. When set, axis 'update' events will be throttled to reduce processing overhead. Trigger and release events are never throttled. (default: undefined/no throttle)
Observable that emits when the active input device changes. Useful for switching button prompts between keyboard and controller styles.
Emits:
'keyboard' - When keyboard input is detected'xbox' - When an Xbox controller is used'playstation' - When a PlayStation controller is used'other_controller' - When another gamepad is usednull - Initial state before any inputGets the ID of the currently active input map.
The active map's ID, or null if no map is set
Destroys the InputManager and releases all resources. Call this when you're done with the manager (e.g., when leaving a scene). After calling destroy, the manager should not be used again.
Gets all currently active commands (triggered but not yet released). Useful for debugging or displaying active input state.
Array of currently active Command instances
Gets the current active input device type.
The current input device type, or null if no input has been detected yet
Checks if an input map with the given ID exists anywhere in the stack.
The input map ID to search for
True if the map exists in the stack
Checks if a specific input key is currently active (pressed/held). Checks across all input sources (keyboard, gamepad).
The input key to check (e.g., Inputs.KEYBOARD_SPACE, Inputs.CONTROLLER_FACE_BOTTOM)
True if the input is currently active
Removes the top input map from the stack. The next map in the stack becomes active. Does nothing if the stack is empty.
Pushes an input map onto the stack, making it the active map. The previous map remains in the stack and will become active again when this map is popped. Use this for temporary contexts like pause menus or dialog boxes.
The input map to push
Releases a custom axes input (sets axes to neutral/center).
The custom axes input name to release
Removes a specific input map from anywhere in the stack by ID.
The input map ID to remove
Replaces all input maps with a single new map. Use this to set the primary input map or switch between major game states.
The input map to set
Starts the tick loop for continuous updates. Required for:
update() events on held inputsTickCommand.tick() callsCall stopTick() or destroy() to stop the loop.
Stops the tick loop. Commands will no longer receive update or tick events.
Triggers a custom axes input. Use this for virtual joysticks, touch controls, etc.
The name must match a customAxesInput field in your input map.
The custom axes input name
The axis values as {x, y} or [x, y]
Triggers a custom single input. Use this for virtual buttons, touch controls, etc.
The input key must match a customInput field in your input map.
The custom input key to trigger
Updates a custom axes input with new values.
The custom axes input name
The new axis values as {x, y} or [x, y]
Central manager for handling all input sources and routing inputs to commands.
InputManager automatically listens to keyboard and gamepad inputs, maps them to commands defined in your input maps, and calls the appropriate command lifecycle methods (trigger, update, release).
Quick Start
Input Map Stacking
InputManager supports stacking input maps for context switching (e.g., gameplay vs menu):
Custom Inputs
Trigger inputs programmatically (e.g., from touch controls):