Gleam - v1.0.2
    Preparing search index...

    Class Keyboard

    Keyboard state. Wired into Game automatically. The preferred way to consume input is to poll isPressed from update — game input is held-state-based ("is W held this frame?"), and combining with stopPress handles one-shot actions cleanly. The EventSystem "inputKeyboard" event (payload: (keys, code, pressed)) is available for cases that genuinely need edge-triggered handling.

    State is cleared on window blur and on gameloopStopped so held keys don't stay "pressed" when focus or the loop is lost. In Settings.debug mode, pressing Escape stops the gameloop.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    keys: Record<string, boolean> = {}

    Live map of KeyboardEvent.code → pressed state. Codes only appear after the key has been touched at least once; missing codes read as undefined (use isPressed for a safe boolean).

    Methods

    • true when code is currently held. Safe for untouched keys (returns false rather than undefined).

      Parameters

      • code: string

      Returns boolean

    • Mark every tracked key as released. Called automatically on window blur and on gameloopStopped.

      Returns void

    • Mark a single key as released — used to consume a press so subsequent ticks don't re-trigger one-shot actions while the key is still held.

      Parameters

      • code: string

      Returns void