Nocturna
    Preparing search index...

    Class InputHandler

    InputHandler manages keyboard input and key bindings for the game.

    Responsibilities:

    • Tracks the state of all relevant keys and maps them to game actions.
    • Supports customizable key bindings and keyboard presets (QWERTY/AZERTY).
    • Handles action callbacks for specific keys (e.g., camera switch, save, delete).
    • Integrates with a KeybindsManager for UI and editing key bindings.
    • Persists key bindings and presets using cookies.
    • Provides methods to pause/resume input handling (e.g., during menus or overlays).
    • Implements the singleton pattern to ensure a single input handler instance.

    Usage:

    • Use InputHandler.getInstance() to access the handler.
    • Register actions with addAction.
    • Query input state with getInput.
    Index

    Methods

    • Registers an action callback for a given key action.

      Parameters

      • key: string

        The action name (e.g., "pov", "save").

      • action: () => void

        The callback function to execute.

      Returns void

    • Returns the current key bindings.

      Returns { [action: string]: string[] }

    • Returns the display name for the first key bound to an action.

      Parameters

      • key: string

        The action name.

      Returns string

      The key name or the action name if not found.

    • Pauses input handling (e.g., when a menu is open).

      Returns void

    • Removes a registered action callback.

      Parameters

      • key: string

        The action name.

      Returns void

    • Removes all registered action callbacks.

      Returns void

    • Executes all registered actions whose keys are currently pressed.

      Returns void

    • Sets the keyboard preset (QWERTY or AZERTY).

      Parameters

      • presetName: string

        The preset name.

      Returns void

    • Updates the key bindings for a specific action and saves to cookies.

      Parameters

      • action: string

        The action name.

      • newKeys: string[]

        The new key(s) to bind.

      Returns void