Skip to content

InputManager

Defined in: InputManager.ts:10

Central input state manager. Resolved via DI with InputManagerKey.

new InputManager(): InputManager

InputManager

_advanceTime(dtMs): void

Defined in: InputManager.ts:410

Internal

Advance the elapsed game-time clock. Called by InputPollSystem.

number

void


_clearFrameState(): void

Defined in: InputManager.ts:394

Internal

Clear per-frame justPressed/justReleased flags.

void


_onKeyDown(code): void

Defined in: InputManager.ts:355

Internal

string

void


_onKeyUp(code): void

Defined in: InputManager.ts:370

Internal

string

void


_onPointerDown(): void

Defined in: InputManager.ts:384

Internal

void


_onPointerMove(screenX, screenY): void

Defined in: InputManager.ts:379

Internal

number

number

void


_onPointerUp(): void

Defined in: InputManager.ts:389

Internal

void


_setCamera(camera): void

Defined in: InputManager.ts:400

Internal

Set camera for pointer world-coord conversion.

CameraLike

void


bindKey(action, key): void

Defined in: InputManager.ts:134

Add a key binding to an action. Creates the action if it doesn’t exist.

string

string

void


cancelListen(): void

Defined in: InputManager.ts:344

Cancel an active listenForNextKey. Resolves the pending promise with null.

void


disableGroup(name): void

Defined in: InputManager.ts:293

Disable a group by name. Actions only in disabled groups become inactive.

string

void


enableGroup(name): void

Defined in: InputManager.ts:288

Enable a group by name.

string

void


exportBindings(): ActionMapDefinition

Defined in: InputManager.ts:252

Export the current bindings as a plain object for serialization.

ActionMapDefinition


getActionNames(): string[]

Defined in: InputManager.ts:405

Get all configured action names.

string[]


getActionsForKey(key): string[]

Defined in: InputManager.ts:161

Returns all action names that have the given key bound.

string

string[]


getAxis(negative, positive): number

Defined in: InputManager.ts:79

Returns -1, 0, or 1 based on negative/positive action states.

string

string

number


getBindings(action): readonly string[]

Defined in: InputManager.ts:156

Returns the current key bindings for an action, or an empty array if unmapped.

string

readonly string[]


getGroupActions(name): readonly string[]

Defined in: InputManager.ts:318

Get the action names belonging to a group. Returns empty array for unknown groups.

string

readonly string[]


getGroups(): string[]

Defined in: InputManager.ts:313

Get all configured group names.

string[]


getHoldDuration(action): number

Defined in: InputManager.ts:57

Milliseconds the action has been held. Returns 0 if not held.

string

number


getPointerPosition(): Vec2

Defined in: InputManager.ts:100

Pointer position in world coordinates (via Camera), or screen coords if no camera.

Vec2


getPointerScreenPosition(): Vec2

Defined in: InputManager.ts:112

Raw pointer position in screen coordinates.

Vec2


getVector(left, right, up, down): Vec2

Defined in: InputManager.ts:86

Returns a Vec2 from four directional actions. Not normalized.

string

string

string

string

Vec2


isGroupEnabled(name): boolean

Defined in: InputManager.ts:308

Whether a group is currently enabled. Returns true for unknown group names.

string

boolean


isHeldFor(action, minTime): boolean

Defined in: InputManager.ts:72

Whether the action has been held for at least minTime ms.

string

number

boolean


isJustPressed(action): boolean

Defined in: InputManager.ts:35

Whether any key mapped to this action was pressed this frame.

string

boolean


isJustReleased(action): boolean

Defined in: InputManager.ts:41

Whether any key mapped to this action was released this frame.

string

boolean


isPointerDown(): boolean

Defined in: InputManager.ts:117

Whether any pointer button is currently held.

boolean


isPressed(action): boolean

Defined in: InputManager.ts:29

Whether any key mapped to this action is currently held.

string

boolean


listenForNextKey(): Promise<string | null>

Defined in: InputManager.ts:336

Returns a promise that resolves with the next key code pressed. Intercepts the key.

Promise<string | null>


loadBindings(map): void

Defined in: InputManager.ts:261

Load bindings from a plain object. Resets to defaults first, then overlays the provided map.

ActionMapDefinition

void


rebind(action, key, opts?): RebindResult

Defined in: InputManager.ts:175

Rebind a key to an action with optional conflict detection. Conflicts are only detected between actions sharing at least one group.

string

string

RebindOptions

RebindResult


resetBindings(action?): void

Defined in: InputManager.ts:237

Reset bindings to defaults. If an action name is provided, only reset that action.

string

void


setActionMap(actions): void

Defined in: InputManager.ts:124

Replace the entire action map and store it as the default for resetBindings.

ActionMapDefinition

void


setActiveGroups(names): void

Defined in: InputManager.ts:298

Set exactly these groups as active; all others are disabled.

string[]

void


setGroups(groups): void

Defined in: InputManager.ts:271

Configure input groups. Group name -> array of action names.

Record<string, string[]>

void


unbindKey(action, key): void

Defined in: InputManager.ts:146

Remove a key binding from an action.

string

string

void