Skip to main content

KeybindManager

Index

Constructors

constructor

  • Initializes with default categories, contexts, and keybindings.


    Returns KeybindManager

Methods

_isKeyComboEqual

  • Returns true if the two keycombos are equal


    Parameters

    Returns boolean

_validateKeyCombo

  • _validateKeyCombo(combo: KeyCombo): boolean

  • Parameters

    Returns boolean

deserialize

  • deserialize(): void
  • Restores keybindings from Player.KeybindingSettings. Registers missing bindings as uninitialized placeholders.


    Returns void

getAllCategories

  • Returns all registered categories.


    Returns Category[]

getAllContexts

  • Returns all registered contexts.


    Returns Context[]

getAllKeybindings

  • Returns all keybindings. Optionally includes uninitialized ones.


    Parameters

    • optionaloptions: {}

      Returns Keybinding[]

    getCategory

    • Returns a category by ID.


      Parameters

      • id: string

      Returns Category

    getCategoryLabel

    • getCategoryLabel(id: chat | maproom | navigation | chatroom | unknown): string
    • Returns the user-visible name of a category


      Parameters

      • id: chat | maproom | navigation | chatroom | unknown

      Returns string

    getConflictingKeybindings

    • getConflictingKeybindings(actionId: string): Keybinding[]
    • Finds keybindings that conflict with the one identified by actionId.


      Parameters

      • actionId: string

      Returns Keybinding[]

    getContext

    • getContext(id: chat | always | isInChatRoom | isOnChatRoomScreen | isChatRoomCharacterMode | isChatRoomMapMode | isChatRoomChatFocused | isChatRoomChatNOTFocused | noModifiers): Context
    • Returns a context by ID.


      Parameters

      • id: chat | always | isInChatRoom | isOnChatRoomScreen | isChatRoomCharacterMode | isChatRoomMapMode | isChatRoomChatFocused | isChatRoomChatNOTFocused | noModifiers

      Returns Context

    getContextLabel

    • getContextLabel(id: chat | always | isInChatRoom | isOnChatRoomScreen | isChatRoomCharacterMode | isChatRoomMapMode | isChatRoomChatFocused | isChatRoomChatNOTFocused | noModifiers): string
    • Returns the user-visible name of a context


      Parameters

      • id: chat | always | isInChatRoom | isOnChatRoomScreen | isChatRoomCharacterMode | isChatRoomMapMode | isChatRoomChatFocused | isChatRoomChatNOTFocused | noModifiers

      Returns string

    getKeybinding

    • Returns a keybinding by its action ID.


      Parameters

      • actionId: string

      Returns Keybinding

    getKeybindingActionDescription

    • getKeybindingActionDescription(actionId: string): string
    • Returns the user-visible description of an action


      Parameters

      • actionId: string

      Returns string

    getKeybindingActionLabel

    • getKeybindingActionLabel(actionId: string): string
    • Returns the user-visible name of an action


      Parameters

      • actionId: string

      Returns string

    getModifiers

    • Extracts modifier keys from a KeyboardEvent into a Set.


      Parameters

      • event: KeyboardEvent

      Returns Set<ModifierKey>

    handleKeyPress

    • handleKeyPress(event: KeyboardEvent): boolean
    • Handles a browser keydown event, triggering matching keybindings if their contexts are active and modifiers match.


      Parameters

      • event: KeyboardEvent

      Returns boolean

      true if handled, otherwise false.

    isDefaultCombo

    registerCategory

    • registerCategory(category: Category): void
    • Registers a new keybinding category. Categories are sorted alphabetically by name after insertion. Logs errors if invalid or already exists.


      Parameters

      Returns void

    registerContext

    • registerContext(context: Context): void
    • Registers a new context with its prerequisite. Contexts are sorted alphabetically by name after insertion. Logs errors if invalid or already exists.


      Parameters

      Returns void

    registerKeybinding

    • Registers a new keybinding. Validates category, contexts, and key combo. Automatically limits modifiers to a max of two.


      Parameters

      Returns void

    serialize

    • serialize(): void
    • Serializes all current keybindings into Player.KeybindingSettings. Compresses using LZString.


      Returns void

    unregisterKeybinding

    • unregisterKeybinding(actionId: string): boolean
    • Removes a keybinding by action ID.


      Parameters

      • actionId: string

      Returns boolean

      true if deleted, false if not found.

    updateKeybinding

    • updateKeybinding(actionId: string, keyCombo: KeyCombo): void
    • Updates the assigned key combo for a keybinding. Logs an error if readonly or not found.


      Parameters

      Returns void