Class KeyboardHandler

KeyboardHandler

A modern keyboard handler that manages keyboard events using a stateful pattern. It supports separate handlers for key down, key up, and continuous key pressed events. The handler calculates a movement vector based on currently pressed keys.

Hierarchy (View Summary)

Constructors

Properties

onKeyDown: (code: string) => boolean
onKeyUp: (code: string) => boolean
onMove: (value: Vector3) => void

Callback invoked whenever the calculated movement vector is updated.

Methods

  • Registers a handler for a key down event.

    Parameters

    • code: string

      The event.code of the key.

    • mode: CallbackMode
    • handler: () => void

      Callback invoked on key down.

    Returns void

  • Registers a handler for a key up event.

    Parameters

    • code: string

      The event.code of the key.

    • mode: CallbackMode
    • handler: () => void

      Callback invoked on key up.

    Returns void