Nano WebGPU API - v0.11.0
    Preparing search index...

    Class InputManager

    InputManager coordinates keyboard and mouse input events, maintaining instantaneous button/key states, delta movement values, and mapping physical keyboard keys to abstract semantic action bindings.

    Index

    Accessors

    • get isMouseCaptured(): boolean

      Determines whether the mouse pointer is currently locked/captured by the browser Pointer Lock API.

      Returns boolean

    Constructors

    Methods

    • Binds an array of hardware event codes to a custom named semantic action.

      Parameters

      • action: string

        Unique identifier name of the action.

      • codes: string[]

        Physical hardware event keys (e.g. ['KeyW', 'ArrowUp']).

      Returns void

    • Tears down all registered event listeners on window and document.

      Returns void

    • Registers event listeners on the global window scope to track keydown, keyup, mousedown, mouseup, mousemove, and pointerlockchange events. Automatically associates with the target canvas element to scope event tracking.

      Parameters

      • OptionalcanvasElement: HTMLCanvasElement

      Returns void

    • Assesses if any physical key mapped to the semantic action was triggered down during the active frame.

      Parameters

      • action: string

        Unique identifier name of the action.

      Returns boolean

      True if any associated key was newly pressed this frame, false otherwise.

    • Assesses if any physical key mapped to the semantic action was released during the active frame.

      Parameters

      • action: string

        Unique identifier name of the action.

      Returns boolean

      True if any associated key was newly released this frame, false otherwise.

    • Assesses if any physical key mapped to the semantic action is currently pressed down.

      Parameters

      • action: string

        Unique identifier name of the action.

      Returns boolean

      True if any associated key is held down, false otherwise.

    • Verifies if a specific keyboard key was pressed down exactly during the active frame.

      Parameters

      • code: string

        The physical keyboard event code (e.g., 'KeyA').

      Returns boolean

      True if newly pressed this frame, false otherwise.

    • Verifies if a specific keyboard key was released exactly during the active frame.

      Parameters

      • code: string

        The physical keyboard event code (e.g., 'KeyS').

      Returns boolean

      True if newly released this frame, false otherwise.

    • Verifies if a specific keyboard key is currently being held down.

      Parameters

      • code: string

        The physical keyboard event code (e.g., 'Space').

      Returns boolean

      True if held down, false otherwise.

    • Verifies if a specific mouse button was pressed down exactly during the active frame.

      Parameters

      • button: number

        The mouse button index (0: Left, 1: Middle, 2: Right).

      Returns boolean

      True if newly pressed this frame, false otherwise.

    • Verifies if a specific mouse button was released exactly during the active frame.

      Parameters

      • button: number

        The mouse button index (0: Left, 1: Middle, 2: Right).

      Returns boolean

      True if newly released this frame, false otherwise.

    • Verifies if a specific mouse button is currently held down.

      Parameters

      • button: number

        The mouse button index (0: Left, 1: Middle, 2: Right).

      Returns boolean

      True if held down, false otherwise.

    • Alters the current MouseMode configuration.

      • "captured": Arms pointer locking. Locking is initiated on the next valid mouse down event.
      • "visible": Immediately exits the browser Pointer Lock context.

      Parameters

      • mode: MouseMode

        The target MouseMode configuration.

      Returns void

    • Resets frame-transient key/button states and resets delta movement values. Must be invoked at the conclusion of every render/update frame loop.

      Returns void

    Properties

    mouseMovement: { x: number; y: number } = ...

    Accumulated delta movement coordinates of the mouse since the last frame.

    mousePosition: { x: number; y: number } = ...

    Absolute coordinates of the mouse pointer within client window space.