InputManager
Defined in: InputManager.ts:216
Central input state manager. Resolved via DI with InputManagerKey.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new InputManager():
InputManager
Returns
Section titled “Returns”InputManager
Methods
Section titled “Methods”_advanceTime()
Section titled “_advanceTime()”_advanceTime(
dtMs):void
Defined in: InputManager.ts:3098
Internal
Advance the elapsed game-time clock. Called by InputPollSystem.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
_applyKeyDown()
Section titled “_applyKeyDown()”_applyKeyDown(
code):void
Defined in: InputManager.ts:2719
Internal
Synthetic key-down. DOM-originated events must use
_enqueueKeyDown so consumePointer and the UI hit-test fallback
have a chance to run before action edges fire.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
_applyKeyUp()
Section titled “_applyKeyUp()”_applyKeyUp(
code):void
Defined in: InputManager.ts:2764
Internal
Synthetic key-up. DOM-originated events must use _enqueueKeyUp.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
_applyPointerCancel()
Section titled “_applyPointerCancel()”_applyPointerCancel(
id):void
Defined in: InputManager.ts:2856
Internal
Synthetic pointer cancel. Clears all buttons on the pointer, fires up-listeners, and drops the entry (unless it’s a mouse). Mirrors the drain-time drainPointerCancel logic.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
_applyPointerDown()
Section titled “_applyPointerDown()”_applyPointerDown(
info):void
Defined in: InputManager.ts:2828
Internal
Synthetic pointer down. DOM-originated events must use _enqueuePointerDown. This applies all state (button mutation, mouse-aggregate emit, listener notify) synchronously.
Parameters
Section titled “Parameters”PointerEventInfo
Returns
Section titled “Returns”void
_applyPointerMove()
Section titled “_applyPointerMove()”_applyPointerMove(
info):void
Defined in: InputManager.ts:2818
Internal
Synthetic pointer move. DOM-originated events must use _enqueuePointerMove.
Parameters
Section titled “Parameters”PointerEventInfo
Returns
Section titled “Returns”void
_applyPointerUp()
Section titled “_applyPointerUp()”_applyPointerUp(
info):void
Defined in: InputManager.ts:2842
Internal
Synthetic pointer up. DOM-originated events must use _enqueuePointerUp.
Parameters
Section titled “Parameters”PointerEventInfo
Returns
Section titled “Returns”void
_clearFrameState()
Section titled “_clearFrameState()”_clearFrameState():
void
Defined in: InputManager.ts:3035
Internal
End-of-frame reset: clear per-frame edge flags and snapshot per-action holds for the next frame’s crossing tests.
Returns
Section titled “Returns”void
_drainInputQueue()
Section titled “_drainInputQueue()”_drainInputQueue():
void
Defined in: InputManager.ts:2493
Internal
Drain queued DOM events at Phase.EarlyUpdate. Each event
applies its deferred state (button mutations, action-map edges,
mouse-aggregate transitions). Consumed pointers are excluded from the
mouse aggregate so UI-claimed presses do not propagate to gameplay
actions. The renderer’s optional hitTestUI(x, y) auto-claims a pointer
whose pointerdown lands on a UI-marked container.
Returns
Section titled “Returns”void
_enqueueKeyDown()
Section titled “_enqueueKeyDown()”_enqueueKeyDown(
code):void
Defined in: InputManager.ts:2411
Internal
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
_enqueueKeyUp()
Section titled “_enqueueKeyUp()”_enqueueKeyUp(
code):void
Defined in: InputManager.ts:2416
Internal
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
_enqueuePointerCancel()
Section titled “_enqueuePointerCancel()”_enqueuePointerCancel(
id):void
Defined in: InputManager.ts:2455
Internal
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
_enqueuePointerDown()
Section titled “_enqueuePointerDown()”_enqueuePointerDown(
info):void
Defined in: InputManager.ts:2430
Internal
Queue a pointer press with the generation assigned at browser dispatch time. Listeners and action edges run together at input drain.
Parameters
Section titled “Parameters”PointerEventInfo
Returns
Section titled “Returns”void
_enqueuePointerMove()
Section titled “_enqueuePointerMove()”_enqueuePointerMove(
info):void
Defined in: InputManager.ts:2421
Internal
Apply pointer movement immediately for live cursor tracking.
Parameters
Section titled “Parameters”PointerEventInfo
Returns
Section titled “Returns”void
_enqueuePointerUp()
Section titled “_enqueuePointerUp()”_enqueuePointerUp(
info):void
Defined in: InputManager.ts:2445
Internal
Parameters
Section titled “Parameters”PointerEventInfo
Returns
Section titled “Returns”void
_enqueueWheel()
Section titled “_enqueueWheel()”_enqueueWheel(
dx,dy,screenX?,screenY?):void
Defined in: InputManager.ts:2481
Internal
Parameters
Section titled “Parameters”number
number
screenX?
Section titled “screenX?”number = 0
screenY?
Section titled “screenY?”number = 0
Returns
Section titled “Returns”void
_onGamepadConnected()
Section titled “_onGamepadConnected()”_onGamepadConnected(
info):void
Defined in: InputManager.ts:1860
Internal
Called by InputPlugin from gamepadconnected event or by
polling when discovering a previously-unknown pad. Idempotent.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
_onGamepadDisconnected()
Section titled “_onGamepadDisconnected()”_onGamepadDisconnected(
info):void
Defined in: InputManager.ts:1878
Internal
Called by InputPlugin from gamepaddisconnected event or by
polling when a pad vanishes silently. Idempotent.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
_onKeyDown()
Section titled “_onKeyDown()”_onKeyDown(
code):void
Defined in: InputManager.ts:3105
Internal
Sync alias — see _applyKeyDown.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
_onKeyUp()
Section titled “_onKeyUp()”_onKeyUp(
code):void
Defined in: InputManager.ts:3109
Internal
Sync alias — see _applyKeyUp.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
_onPointerCancel()
Section titled “_onPointerCancel()”_onPointerCancel(
id):void
Defined in: InputManager.ts:3125
Internal
Sync alias — see _applyPointerCancel.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
_onPointerDown()
Section titled “_onPointerDown()”_onPointerDown(
info):void
Defined in: InputManager.ts:3117
Internal
Sync alias — see _applyPointerDown.
Parameters
Section titled “Parameters”PointerEventInfo
Returns
Section titled “Returns”void
_onPointerMove()
Section titled “_onPointerMove()”_onPointerMove(
info):void
Defined in: InputManager.ts:3113
Internal
Sync alias — see _applyPointerMove.
Parameters
Section titled “Parameters”PointerEventInfo
Returns
Section titled “Returns”void
_onPointerUp()
Section titled “_onPointerUp()”_onPointerUp(
info):void
Defined in: InputManager.ts:3121
Internal
Sync alias — see _applyPointerUp.
Parameters
Section titled “Parameters”PointerEventInfo
Returns
Section titled “Returns”void
_pollGamepads()
Section titled “_pollGamepads()”_pollGamepads():
void
Defined in: InputManager.ts:1920
Internal
Poll real gamepads via navigator.getGamepads() and emit
key-down/key-up edges for any aggregate state changes. Called by
InputPollSystem once per frame.
Returns
Section titled “Returns”void
_registerClock()
Section titled “_registerClock()”_registerClock(
clock):void
Defined in: InputManager.ts:864
Internal
Register a clock so press edges and hold starts capture its current reading. Input already held is stamped at registration, so an ongoing hold starts from zero on the new clock instead of reading as not held. A press made before registration is not backfilled — it happened outside this clock’s timeline.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
_releaseActionSource()
Section titled “_releaseActionSource()”_releaseActionSource(
sourceId):void
Defined in: InputManager.ts:2211
Internal
Called by the source returned from createActionSource.
Parameters
Section titled “Parameters”sourceId
Section titled “sourceId”number
Returns
Section titled “Returns”void
_releaseAllGamepadState()
Section titled “_releaseAllGamepadState()”_releaseAllGamepadState():
void
Defined in: InputManager.ts:1849
Internal
Force-release held gamepad buttons and clear real-pad analog
snapshots. Used on tab-hide (where navigator.getGamepads() returns
stale data) and on disconnect when polling is paused. Synthetic axes
live in their own field, so they’re untouched.
Returns
Section titled “Returns”void
_releaseAllPhysicalState()
Section titled “_releaseAllPhysicalState()”_releaseAllPhysicalState():
void
Defined in: InputManager.ts:2292
Internal
Release physical input on window blur or page hide, then discard browser events queued before the boundary.
Returns
Section titled “Returns”void
_setActionSourceHeld()
Section titled “_setActionSourceHeld()”_setActionSourceHeld(
sourceId,action,held):void
Defined in: InputManager.ts:2181
Internal
Called by the source returned from createActionSource.
Parameters
Section titled “Parameters”sourceId
Section titled “sourceId”number
action
Section titled “action”string
boolean
Returns
Section titled “Returns”void
_setErrorBoundary()
Section titled “_setErrorBoundary()”_setErrorBoundary(
boundary):void
Defined in: InputManager.ts:2396
Internal
Wire the error boundary so a throwing key/action listener is
attributed and reported. Called by InputPlugin.install.
Parameters
Section titled “Parameters”boundary
Section titled “boundary”ErrorBoundary | undefined
Returns
Section titled “Returns”void
_setRenderer()
Section titled “_setRenderer()”_setRenderer(
renderer):void
Defined in: InputManager.ts:2388
Internal
Stash the renderer adapter so the drain step can call its
optional hitTestUI(x, y) for the auto-consume fallback. Called by
InputPlugin.install.
Parameters
Section titled “Parameters”renderer
Section titled “renderer”RendererAdapter | null
Returns
Section titled “Returns”void
_setScheduler()
Section titled “_setScheduler()”_setScheduler(
scheduler):void
Defined in: InputManager.ts:2406
Internal
Wire the scheduler so edge queries can resolve the caller’s
execution context (phase and fixed step). Called by
InputPlugin.registerSystems. When never wired (standalone manager),
every query resolves against the frame window.
Parameters
Section titled “Parameters”scheduler
Section titled “scheduler”Returns
Section titled “Returns”void
_unregisterClock()
Section titled “_unregisterClock()”_unregisterClock(
clock):void
Defined in: InputManager.ts:880
Internal
Drop a clock and everything measured on it.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
bindKey()
Section titled “bindKey()”bindKey(
action,key):void
Defined in: InputManager.ts:1269
Add a key binding to an action. Creates the action if it doesn’t exist.
Parameters
Section titled “Parameters”action
Section titled “action”string
string
Returns
Section titled “Returns”void
cancelListen()
Section titled “cancelListen()”cancelListen():
void
Defined in: InputManager.ts:1483
Cancel an active listenForNextKey. Resolves the pending promise with null.
Returns
Section titled “Returns”void
clearAll()
Section titled “clearAll()”clearAll():
void
Defined in: InputManager.ts:2222
Release all synthetic and physical input state.
Returns
Section titled “Returns”void
clearCamera()
Section titled “clearCamera()”clearCamera():
void
Defined in: InputManager.ts:3088
Clear the camera reference (e.g. on scene exit).
Returns
Section titled “Returns”void
clearPointerButtons()
Section titled “clearPointerButtons()”clearPointerButtons():
void
Defined in: InputManager.ts:2274
Drop all tracked pointers and release the aggregate MouseLeft/Middle/Right
codes without touching keyboard or gamepad state. Useful for window-blur
/ page-hide handling.
Returns
Section titled “Returns”void
consumeBufferedPress()
Section titled “consumeBufferedPress()”consumeBufferedPress(
action,windowSeconds,options?):boolean
Defined in: InputManager.ts:825
Consuming buffered-press query: true if the action was pressed within the
last windowSeconds and that press has not yet been claimed. Claims the
press on success, so it returns true at most once per press; only a new
press clears the claim (last-press-wins, no queue). Consumption is scoped
to this query — isJustPressed and action listeners still see every
press.
Lets a consumer act on a press up to windowSeconds late (e.g. jump
buffered just before landing) without the press re-triggering later.
The window counts on the raw input clock (getClockTime), which
ignores scene pause and time scale. Pass options.clock — the SceneTime
of a scene on the stack — to count it on that scene’s simulation time
instead; any other clock throws. One press is claimed once whichever clock
measured it.
A disabled action returns false without claiming, so a discard-on-resume call has to run with the action enabled to drop a press buffered earlier.
Parameters
Section titled “Parameters”action
Section titled “action”string
windowSeconds
Section titled “windowSeconds”number
options?
Section titled “options?”Returns
Section titled “Returns”boolean
consumePointer()
Section titled “consumePointer()”consumePointer(
id):void
Defined in: InputManager.ts:1100
Mark a pointer as claimed for the rest of its event cycle (down → up).
Subsequent action-map edges for this pointer (e.g. the MouseLeft edge a
pointerdown would normally fire) are suppressed; onPointerDown/Up/Move
listeners still fire because they are explicit user opt-ins.
Two cases use this:
-
A UI handler claims a real event. Call from a Pixi
pointerdownhandler that wants to own the event:manager.consumePointer(e.pointerId). -
You forwarded or replayed a synthetic pointer to the canvas and need it kept out of gameplay actions. A DOM overlay above the canvas (virtual joystick, accessibility overlay, input-replay tooling) that dispatches a synthetic
PointerEventto the canvas — so listeners underneath still receive it — must pair the dispatch withconsumePointeror every forwarded tap leaks into theMouseLeft/Middle/Rightaction edge:canvas.dispatchEvent(syntheticPointerDown); // underneath listeners still fireinput.consumePointer(e.pointerId); // but no gameplay action edge
The mark clears automatically when the pointer’s last button releases or
on pointercancel.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
consumeWheel()
Section titled “consumeWheel()”consumeWheel():
void
Defined in: InputManager.ts:1139
Suppress action-map edges for the wheel event currently notifying its listeners. Calling outside an onWheel callback throws.
Returns
Section titled “Returns”void
createActionSource()
Section titled “createActionSource()”createActionSource():
InputActionSource
Defined in: InputManager.ts:2176
Create an independently releasable producer of sustained action presses. Create one source per virtual device, replay driver, or other owner.
Returns
Section titled “Returns”disableGroup()
Section titled “disableGroup()”disableGroup(
name):void
Defined in: InputManager.ts:1432
Disable a group by name. Actions only in disabled groups become inactive.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
enableGroup()
Section titled “enableGroup()”enableGroup(
name):void
Defined in: InputManager.ts:1427
Enable a group by name.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
exportBindings()
Section titled “exportBindings()”exportBindings():
ActionMapDefinition
Defined in: InputManager.ts:1391
Export the current bindings as a plain object for serialization.
Returns
Section titled “Returns”fireAction()
Section titled “fireAction()”fireAction(
name):void
Defined in: InputManager.ts:2152
Inject a one-frame synthetic action pulse.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
fireGamepadAxis()
Section titled “fireGamepadAxis()”fireGamepadAxis(
side,value):void
Defined in: InputManager.ts:1607
Inject a synthetic gamepad axis value. Stored separately from real-pad
axis state and consulted by getStick / getTrigger when no real pad
is active, or when the active pad’s own input rests inside the deadzone
— so test fixtures and virtual sticks read back even while an idle
controller sits plugged in; a pad deflected past the deadzone wins.
Trigger axes additionally emit GamepadLT/GamepadRT button edges when
crossing triggerThreshold, mirroring real-pad polling so synthetic
inspector probes drive isPressed the same way as physical hardware.
Stick values must be finite and in [-1, 1]; triggers must be finite and
in [0, 1].
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
fireGamepadButton()
Section titled “fireGamepadButton()”fireGamepadButton(
code,pressed):void
Defined in: InputManager.ts:1583
Inject a synthetic gamepad button edge. Routes through the same internal
path as real polling, so action queries (isPressed, isJustPressed),
listenForNextKey, and rebinding all see the synthetic input.
code should be a gamepad code string (e.g. "GamepadA", "GamepadLT").
Used by inspector probes / deterministic tests in lieu of real polling.
Parameters
Section titled “Parameters”string
pressed
Section titled “pressed”boolean
Returns
Section titled “Returns”void
fireKeyDown()
Section titled “fireKeyDown()”fireKeyDown(
code):void
Defined in: InputManager.ts:1492
Public wrapper for synthetic key-down injection. Applies sync.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
fireKeyUp()
Section titled “fireKeyUp()”fireKeyUp(
code):void
Defined in: InputManager.ts:1497
Public wrapper for synthetic key-up injection. Applies sync.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
firePointerDown()
Section titled “firePointerDown()”firePointerDown(
button?,opts?):void
Defined in: InputManager.ts:1519
Public wrapper for synthetic pointer-button presses. Defaults to button 0
on the primary mouse pointer. Pass opts for touch / pen / non-primary
pointers (e.g. { id: 5, type: "touch", isPrimary: false }).
Parameters
Section titled “Parameters”button?
Section titled “button?”0 | 1 | 2
number
isPrimary?
Section titled “isPrimary?”boolean
Returns
Section titled “Returns”void
firePointerMove()
Section titled “firePointerMove()”firePointerMove(
screenX,screenY,opts?):void
Defined in: InputManager.ts:1506
Public wrapper for synthetic pointer movement. Defaults to the primary
mouse pointer (id: 1, type: "mouse"); pass opts to drive a specific
touch / pen pointer.
Parameters
Section titled “Parameters”screenX
Section titled “screenX”number
screenY
Section titled “screenY”number
number
isPrimary?
Section titled “isPrimary?”boolean
Returns
Section titled “Returns”void
firePointerUp()
Section titled “firePointerUp()”firePointerUp(
button?,opts?):void
Defined in: InputManager.ts:1536
Public wrapper for synthetic pointer-button releases.
Parameters
Section titled “Parameters”button?
Section titled “button?”0 | 1 | 2
number
Returns
Section titled “Returns”void
fireWheel()
Section titled “fireWheel()”fireWheel(
dx,dy):void
Defined in: InputManager.ts:1553
Public wrapper for synthetic wheel input. Applies sync, including
action edges and onWheel listener notification — matching the DOM path
so tests and inspector probes drive the full surface.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
gamepads()
Section titled “gamepads()”gamepads(): readonly
GamepadInfo[]
Defined in: InputManager.ts:1691
Synchronously poll navigator.getGamepads() for currently-connected pads.
Use this rather than the cached event-driven list when you need ground
truth — gamepadconnected doesn’t fire until the user presses a button.
Returns
Section titled “Returns”readonly GamepadInfo[]
getActionNames()
Section titled “getActionNames()”getActionNames():
string[]
Defined in: InputManager.ts:3093
Get all configured action names.
Returns
Section titled “Returns”string[]
getActionsForKey()
Section titled “getActionsForKey()”getActionsForKey(
key):string[]
Defined in: InputManager.ts:1296
Returns all action names that have the given key bound.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string[]
getActivePad()
Section titled “getActivePad()”getActivePad():
GamepadInfo|null
Defined in: InputManager.ts:1742
The pad whose analog input is read by default. Auto-promotes on input
activity (button press or stick/trigger above deadzone) and on first
connect. Returns null when no pad is connected.
Returns
Section titled “Returns”GamepadInfo | null
getAxis()
Section titled “getAxis()”getAxis(
negative,positive):number
Defined in: InputManager.ts:925
Returns -1, 0, or 1 based on negative/positive action states.
Parameters
Section titled “Parameters”negative
Section titled “negative”string
positive
Section titled “positive”string
Returns
Section titled “Returns”number
getBindings()
Section titled “getBindings()”getBindings(
action): readonlystring[]
Defined in: InputManager.ts:1291
Returns the current key bindings for an action, or an empty array if unmapped.
Parameters
Section titled “Parameters”action
Section titled “action”string
Returns
Section titled “Returns”readonly string[]
getClockTime()
Section titled “getClockTime()”getClockTime():
number
Defined in: InputManager.ts:653
Seconds elapsed on the raw input clock.
This clock advances from the engine’s unscaled frame time. Scene pause and time scaling do not affect it.
Returns
Section titled “Returns”number
getGroupActions()
Section titled “getGroupActions()”getGroupActions(
name): readonlystring[]
Defined in: InputManager.ts:1457
Get the action names belonging to a group. Returns empty array for unknown groups.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”readonly string[]
getGroups()
Section titled “getGroups()”getGroups():
string[]
Defined in: InputManager.ts:1452
Get all configured group names.
Returns
Section titled “Returns”string[]
getHoldDuration()
Section titled “getHoldDuration()”getHoldDuration(
action,options?):number
Defined in: InputManager.ts:636
Seconds the action has been held. Returns 0 if not held.
The duration counts on the raw input clock (getClockTime), which
ignores scene pause and time scale — a charge keeps charging through a
pause menu. Pass options.clock — the SceneTime of a scene on the stack
— to count it on that scene’s simulation time instead, so the hold stops
with the scene and follows its time scale; any other clock throws.
Parameters
Section titled “Parameters”action
Section titled “action”string
options?
Section titled “options?”Returns
Section titled “Returns”number
getPointer()
Section titled “getPointer()”getPointer(
id):PointerInfo|undefined
Defined in: InputManager.ts:982
Direct lookup by pointerId, or undefined if no pointer with that id is tracked.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”PointerInfo | undefined
getPointerPosition()
Section titled “getPointerPosition()”getPointerPosition():
Vec2
Defined in: InputManager.ts:947
Primary pointer’s position in world coordinates (via Camera), or screen
coords if no camera. Returns Vec2.ZERO when no pointer is tracked.
For multi-pointer access (touch UIs etc.) iterate getPointers and
convert each screenPos via the camera as needed.
Returns
Section titled “Returns”Vec2
getPointerPresses()
Section titled “getPointerPresses()”getPointerPresses(
options?): readonlyPointerPressInfo[]
Defined in: InputManager.ts:993
Pointer-down edges from the current rendered frame.
Claimed presses are excluded by default. Use consumed: "include" to
return every press or consumed: "only" to inspect claimed presses.
Parameters
Section titled “Parameters”options?
Section titled “options?”PointerPressOptions = {}
Returns
Section titled “Returns”readonly PointerPressInfo[]
getPointers()
Section titled “getPointers()”getPointers(): readonly
PointerInfo[]
Defined in: InputManager.ts:973
All currently-tracked pointers (one per active mouse, pen, or finger).
Returns
Section titled “Returns”readonly PointerInfo[]
getPointerScreenPosition()
Section titled “getPointerScreenPosition()”getPointerScreenPosition():
Vec2
Defined in: InputManager.ts:961
Primary pointer’s raw position in screen coordinates, or Vec2.ZERO when no pointer is tracked.
Returns
Section titled “Returns”Vec2
getReleaseDuration()
Section titled “getReleaseDuration()”getReleaseDuration(
action,options?):number
Defined in: InputManager.ts:725
Seconds the action was held, valid only in the query window where the action is fully released — the last pressed binding (key or synthetic) lets go; a chord’s partial release reports 0. The window is the current frame or the current fixed step, matching the calling context like isJustPressed. Captured at the release edge, so it survives getHoldDuration resetting to 0 in that same window — no sample-before-release dance needed.
The length counts on the raw input clock unless options.clock names a
registered scene clock, like getHoldDuration. Each clock captures
its own length at the release, so a hold spanning a pause reports the
scene’s simulation seconds on the scene clock, and the whole span
including the pause on the raw one. A
hold that began before a clock was registered reports only the part
measured since, matching how it counted while held.
Parameters
Section titled “Parameters”action
Section titled “action”string
options?
Section titled “options?”Returns
Section titled “Returns”number
getStick()
Section titled “getStick()”getStick(
side,opts?):Vec2
Defined in: InputManager.ts:1641
Returns the deadzoned, magnitude-clamped stick vector for the given side.
By default reads from the active pad (the most recently used controller,
or the first connected one if nothing has been used yet). Pass
{ pad: index } to read only that physical pad — useful for couch-co-op
where each player’s controller is addressed explicitly. Explicit reads
return zero rather than falling back to synthetic axes.
Falls back to synthetic injection (fireGamepadAxis) when no pad is
active — the test/probe/virtual-controls path — AND when the pad’s own
stick rests inside the deadzone: a controller merely sitting plugged in
(its resting noise stays inside the deadzone) must not mask a virtual
stick that is actively deflected. A pad deflected past the deadzone
always wins.
Parameters
Section titled “Parameters”"left" | "right"
number
Returns
Section titled “Returns”Vec2
getTrigger()
Section titled “getTrigger()”getTrigger(
side,opts?):number
Defined in: InputManager.ts:1667
Returns the deadzoned trigger value (0..1) for the given side.
Reads from the active pad by default; use { pad: index } to read only
that physical pad. Default reads fall back to synthetic state when no pad
is active or the active pad’s trigger rests inside the deadzone (mirrors
getStick).
Parameters
Section titled “Parameters”"left" | "right"
number
Returns
Section titled “Returns”number
getVector()
Section titled “getVector()”getVector(
left,right,up,down):Vec2
Defined in: InputManager.ts:932
Returns a Vec2 from four directional actions. Not normalized.
Parameters
Section titled “Parameters”string
string
string
string
Returns
Section titled “Returns”Vec2
hasAction()
Section titled “hasAction()”hasAction(
name):boolean
Defined in: InputManager.ts:2147
Whether name is defined in the current action map.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
isGroupEnabled()
Section titled “isGroupEnabled()”isGroupEnabled(
name):boolean
Defined in: InputManager.ts:1447
Whether a group is currently enabled. Returns true for unknown group names.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
isHeldFor()
Section titled “isHeldFor()”isHeldFor(
action,minSeconds,options?):boolean
Defined in: InputManager.ts:662
Whether the action has been held for at least minSeconds. Counts on the
raw input clock unless options.clock names a registered scene clock,
like getHoldDuration.
Parameters
Section titled “Parameters”action
Section titled “action”string
minSeconds
Section titled “minSeconds”number
options?
Section titled “options?”Returns
Section titled “Returns”boolean
isJustHeldFor()
Section titled “isJustHeldFor()”isJustHeldFor(
action,seconds,options?):boolean
Defined in: InputManager.ts:687
Hold-start edge: true only in the query window where the action’s hold
crosses seconds — the current frame or the current fixed step,
matching the calling context like isJustPressed. Threshold-
crossing math over the hold clock, so any call-site threshold works
with no per-action config. Drives “released before T = a tap, crossed
T = hold-start” input feel. A tap (released before the threshold) never
fires it — the hold resets to 0 in the release window.
The hold counts on the raw input clock unless options.clock names a
registered scene clock, like getHoldDuration. Each clock carries
its own crossing baseline, so a threshold reached on scene time fires
exactly once there whatever the raw clock has done meanwhile.
Parameters
Section titled “Parameters”action
Section titled “action”string
seconds
Section titled “seconds”number
options?
Section titled “options?”Returns
Section titled “Returns”boolean
isJustPressed()
Section titled “isJustPressed()”isJustPressed(
action,options?):boolean
Defined in: InputManager.ts:402
Whether a press edge for the action landed in the caller’s query window.
The window matches the calling context. From frame-phase code (update,
listeners, any non-fixed system) it is the current rendered frame. From
fixed-step code (fixedUpdate, Phase.FixedUpdate systems) it is the
current fixed step: the edges that arrived since the previous step began.
Each context sees a press exactly once — when several fixed steps run in
one frame only the first sees it, and a press in a frame that runs no
fixed step is held for the next step.
With { repeat: true } a held action also reports an edge in every window
where its hold crosses repeatDelay + n * repeatInterval. At most one
edge per query window: a frame longer than the interval steps a menu one
row. The rate is an argument, so two callers can repeat the same action
at different rates. Gamepad stick directions repeat like any key.
options.clock selects the clock the repeat schedule is counted on; the
initial press edge always resolves against the caller’s own window.
Omitted, repeats count on the raw input clock, so a menu keeps repeating
over a paused scene.
Parameters
Section titled “Parameters”action
Section titled “action”string
options?
Section titled “options?”Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”when repeatDelay is not a finite number at or above 0, or
repeatInterval is not a finite number above 0, before any state is read.
isJustReleased()
Section titled “isJustReleased()”isJustReleased(
action):boolean
Defined in: InputManager.ts:459
Whether a release edge for the action landed in the caller’s query window — the current frame or the current fixed step, matching the calling context like isJustPressed.
Parameters
Section titled “Parameters”action
Section titled “action”string
Returns
Section titled “Returns”boolean
isJustReleasedAfter()
Section titled “isJustReleasedAfter()”isJustReleasedAfter(
action,minSeconds,options?):boolean
Defined in: InputManager.ts:789
True in the query window where the action is fully released — frame or
fixed step, matching the calling context like isJustPressed —
if it was held for at least minSeconds. Counts on the raw input clock
unless options.clock names a registered scene clock, like
getHoldDuration.
False when the clock holds no length for the release, as in isJustTapped.
Parameters
Section titled “Parameters”action
Section titled “action”string
minSeconds
Section titled “minSeconds”number
options?
Section titled “options?”Returns
Section titled “Returns”boolean
isJustReleasedByPlayer()
Section titled “isJustReleasedByPlayer()”isJustReleasedByPlayer(
action):boolean
Defined in: InputManager.ts:483
Whether the player let go of the action in the caller’s query window, matching the calling context like isJustPressed.
A key-up, a gamepad button-up, a pointer-button release and a finger leaving an on-screen control count. Held state the engine drops does not: window blur, page hide, a pad disconnecting, a cancelled pointer, clearAll, an action source released. Those still notify onActionReleased, and isJustReleased reports them.
Read this where the release commits something the player cannot take back (a menu confirm, a charged shot), so alt-tabbing commits nothing.
A hold that ends while the action’s group is disabled answers false.
Parameters
Section titled “Parameters”action
Section titled “action”string
Returns
Section titled “Returns”boolean
isJustTapped()
Section titled “isJustTapped()”isJustTapped(
action,maxSeconds,options?):boolean
Defined in: InputManager.ts:766
True in the query window where the action is fully released — frame or
fixed step, matching the calling context like isJustPressed —
if it was held for at most maxSeconds. Counts on the raw input clock
unless options.clock names a registered scene clock, like
getHoldDuration.
False when the clock holds no length for the release — one that predates the clock’s registration, or landed while the action’s group was disabled. An unmeasured hold is not a tap.
Parameters
Section titled “Parameters”action
Section titled “action”string
maxSeconds
Section titled “maxSeconds”number
options?
Section titled “options?”Returns
Section titled “Returns”boolean
isPointerConsumed()
Section titled “isPointerConsumed()”isPointerConsumed(
id):boolean
Defined in: InputManager.ts:1116
Whether the pointer is currently marked consumed.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”boolean
isPointerDown()
Section titled “isPointerDown()”isPointerDown():
boolean
Defined in: InputManager.ts:967
Whether the primary pointer has any button held.
Returns
Section titled “Returns”boolean
isPollingEnabled()
Section titled “isPollingEnabled()”isPollingEnabled():
boolean
Defined in: InputManager.ts:1797
Whether real gamepad polling is currently enabled.
Returns
Section titled “Returns”boolean
isPressed()
Section titled “isPressed()”isPressed(
action):boolean
Defined in: InputManager.ts:370
Whether any key mapped to this action is currently held.
Parameters
Section titled “Parameters”action
Section titled “action”string
Returns
Section titled “Returns”boolean
listenForNextKey()
Section titled “listenForNextKey()”listenForNextKey():
Promise<string|null>
Defined in: InputManager.ts:1475
Returns a promise that resolves with the next key code pressed. Intercepts the key.
Returns
Section titled “Returns”Promise<string | null>
loadBindings()
Section titled “loadBindings()”loadBindings(
map):void
Defined in: InputManager.ts:1400
Load bindings from a plain object. Resets to defaults first, then overlays the provided map.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
onAction()
Section titled “onAction()”onAction(
name,fn): () =>void
Defined in: InputManager.ts:1207
Subscribe to action press edges (rising edge of any key bound to the action). Fires once per press. Returns a disposer.
Parameters
Section titled “Parameters”string
(name) => void
Returns
Section titled “Returns”() => void
onActionReleased()
Section titled “onActionReleased()”onActionReleased(
name,fn): () =>void
Defined in: InputManager.ts:1223
Subscribe to action release edges. Returns a disposer.
Parameters
Section titled “Parameters”string
(name) => void
Returns
Section titled “Returns”() => void
onActivePadChanged()
Section titled “onActivePadChanged()”onActivePadChanged(
fn): () =>void
Defined in: InputManager.ts:1762
Subscribe to active-pad changes. Replays the current active pad
synchronously on subscribe so callers get the present state without a
separate getActivePad() call. Returns a disposer.
Parameters
Section titled “Parameters”(info) => void
Returns
Section titled “Returns”() => void
onGamepadConnected()
Section titled “onGamepadConnected()”onGamepadConnected(
fn): () =>void
Defined in: InputManager.ts:1710
Subscribe to gamepad-connected events. Replays currently-known pads
synchronously so callers don’t need a separate gamepads() call.
Returns a disposer.
Parameters
Section titled “Parameters”(info) => void
Returns
Section titled “Returns”() => void
onGamepadDisconnected()
Section titled “onGamepadDisconnected()”onGamepadDisconnected(
fn): () =>void
Defined in: InputManager.ts:1727
Subscribe to gamepad-disconnected events. Returns a disposer.
Parameters
Section titled “Parameters”(info) => void
Returns
Section titled “Returns”() => void
onKeyDown()
Section titled “onKeyDown()”onKeyDown(
code,fn): () =>void
Defined in: InputManager.ts:1158
Subscribe to key-down events. Pass a code (e.g. "Space", "GamepadA")
to filter, or "*" for all keys. The listener fires on the same edge
isJustPressed reports — for DOM-originated events that’s the next
Phase.EarlyUpdate after the browser dispatches; for synthetic injection
(fireKeyDown) it’s synchronous. Returns a disposer.
Parameters
Section titled “Parameters”string
(code) => void
Returns
Section titled “Returns”() => void
onKeyUp()
Section titled “onKeyUp()”onKeyUp(
code,fn): () =>void
Defined in: InputManager.ts:1181
Subscribe to key-up events. See onKeyDown.
Parameters
Section titled “Parameters”string
(code) => void
Returns
Section titled “Returns”() => void
onPointerDown()
Section titled “onPointerDown()”onPointerDown(
fn): () =>void
Defined in: InputManager.ts:1042
Subscribe to pointer-down events (button transitions from up → down on a tracked pointer). DOM listeners run during input drain, after the UI hit-test and before the button/action edge applies. Returns a disposer.
Parameters
Section titled “Parameters”(info) => void
Returns
Section titled “Returns”() => void
onPointerMove()
Section titled “onPointerMove()”onPointerMove(
fn): () =>void
Defined in: InputManager.ts:1064
Subscribe to pointer-move events. Returns a disposer.
Parameters
Section titled “Parameters”(info) => void
Returns
Section titled “Returns”() => void
onPointerUp()
Section titled “onPointerUp()”onPointerUp(
fn): () =>void
Defined in: InputManager.ts:1055
Subscribe to pointer-up events (button transitions from down → up, plus
touch / pen lifecycle ends and pointercancel). DOM listeners run during
input drain before the button/action edge applies. Returns a disposer.
Parameters
Section titled “Parameters”(info) => void
Returns
Section titled “Returns”() => void
onWheel()
Section titled “onWheel()”onWheel(
fn): () =>void
Defined in: InputManager.ts:1243
Subscribe to scroll-wheel events. Receives raw deltaX/deltaY (already
sign-flipped by InputConfig.wheelInvertY if set). Fires regardless of
consumeWheel — it only gates action edges. Returns a disposer.
Parameters
Section titled “Parameters”(dx, dy) => void
Returns
Section titled “Returns”() => void
rebind()
Section titled “rebind()”rebind(
action,key,opts?):RebindResult
Defined in: InputManager.ts:1310
Rebind a key to an action with optional conflict detection. Conflicts are only detected between actions sharing at least one group.
Parameters
Section titled “Parameters”action
Section titled “action”string
string
Returns
Section titled “Returns”resetBindings()
Section titled “resetBindings()”resetBindings(
action?):void
Defined in: InputManager.ts:1376
Reset bindings to defaults. If an action name is provided, only reset that action.
Parameters
Section titled “Parameters”action?
Section titled “action?”string
Returns
Section titled “Returns”void
setActionMap()
Section titled “setActionMap()”setActionMap(
actions):void
Defined in: InputManager.ts:1259
Replace the entire action map and store it as the default for resetBindings.
Parameters
Section titled “Parameters”actions
Section titled “actions”Returns
Section titled “Returns”void
setActiveGroups()
Section titled “setActiveGroups()”setActiveGroups(
names):void
Defined in: InputManager.ts:1437
Set exactly these groups as active; all others are disabled.
Parameters
Section titled “Parameters”string[]
Returns
Section titled “Returns”void
setActivePad()
Section titled “setActivePad()”setActivePad(
index):void
Defined in: InputManager.ts:1752
Manually set the active pad. Index must match a currently connected pad
— pass an unknown index and the call is a no-op. Pass null to clear
(analog reads will fall back to synthetic state if any).
Parameters
Section titled “Parameters”number | null
Returns
Section titled “Returns”void
setCamera()
Section titled “setCamera()”setCamera(
camera):void
Defined in: InputManager.ts:3083
Set camera for pointer world-coord conversion.
Parameters
Section titled “Parameters”camera
Section titled “camera”Returns
Section titled “Returns”void
setDeadzones()
Section titled “setDeadzones()”setDeadzones(
opts):void
Defined in: InputManager.ts:1805
Update analog deadzones at runtime. Either field may be omitted.
Values must be finite and in [0, 1).
Parameters
Section titled “Parameters”stick?
Section titled “stick?”number
trigger?
Section titled “trigger?”number
Returns
Section titled “Returns”void
setGroups()
Section titled “setGroups()”setGroups(
groups):void
Defined in: InputManager.ts:1410
Configure input groups. Group name -> array of action names.
Parameters
Section titled “Parameters”groups
Section titled “groups”Record<string, string[]>
Returns
Section titled “Returns”void
setPollingEnabled()
Section titled “setPollingEnabled()”setPollingEnabled(
enabled):void
Defined in: InputManager.ts:1792
Enable or disable real gamepad polling. Synthetic injection still works when disabled.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”void
setTriggerThreshold()
Section titled “setTriggerThreshold()”setTriggerThreshold(
value):void
Defined in: InputManager.ts:1832
Set the trigger button-edge threshold (default 0.5). Must be finite and in
(0, 1].
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
snapshotState()
Section titled “snapshotState()”snapshotState():
object
Defined in: InputManager.ts:2310
Snapshot of current held input state for inspector tooling.
Returns
Section titled “Returns”object
actions
Section titled “actions”actions:
string[]
gamepad
Section titled “gamepad”gamepad:
object
gamepad.axes
Section titled “gamepad.axes”axes:
object[]
gamepad.buttons
Section titled “gamepad.buttons”buttons:
string[]
keys:
string[]
mouse:
object
mouse.buttons
Section titled “mouse.buttons”buttons:
number[]
mouse.down
Section titled “mouse.down”down:
boolean
mouse.x
Section titled “mouse.x”x:
number
mouse.y
Section titled “mouse.y”y:
number
pointers
Section titled “pointers”pointers:
object[]
unbindKey()
Section titled “unbindKey()”unbindKey(
action,key):void
Defined in: InputManager.ts:1281
Remove a key binding from an action.
Parameters
Section titled “Parameters”action
Section titled “action”string
string
Returns
Section titled “Returns”void
Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/input.md.