KeybindManager
Index
Constructors
Methods
- _isKeyComboEqual
- _validateKeyCombo
- deserialize
- getAllCategories
- getAllContexts
- getAllKeybindings
- getCategory
- getCategoryLabel
- getConflictingKeybindings
- getContext
- getContextLabel
- getKeybinding
- getKeybindingActionDescription
- getKeybindingActionLabel
- getModifiers
- handleKeyPress
- isDefaultCombo
- registerCategory
- registerContext
- registerKeybinding
- serialize
- unregisterKeybinding
- updateKeybinding
Constructors
constructor
Returns KeybindManager
Methods
_isKeyComboEqual
_validateKeyCombo
Parameters
combo: KeyCombo
Returns boolean
deserialize
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
Returns the user-visible name of a category
Parameters
id: chat | maproom | navigation | chatroom | unknown
Returns string
getConflictingKeybindings
Finds keybindings that conflict with the one identified by
actionId.Parameters
actionId: string
Returns Keybinding[]
getContext
Returns a context by ID.
Parameters
id: chat | always | isInChatRoom | isOnChatRoomScreen | isChatRoomCharacterMode | isChatRoomMapMode | isChatRoomChatFocused | isChatRoomChatNOTFocused | noModifiers
Returns Context
getContextLabel
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
Returns the user-visible description of an action
Parameters
actionId: string
Returns string
getKeybindingActionLabel
Returns the user-visible name of an action
Parameters
actionId: string
Returns string
getModifiers
Extracts modifier keys from a
KeyboardEventinto a Set.Parameters
event: KeyboardEvent
Returns Set<ModifierKey>
handleKeyPress
Handles a browser
keydownevent, triggering matching keybindings if their contexts are active and modifiers match.Parameters
event: KeyboardEvent
Returns boolean
trueif handled, otherwisefalse.
isDefaultCombo
Parameters
keybinding: Keybinding
Returns boolean
registerCategory
Registers a new keybinding category. Categories are sorted alphabetically by name after insertion. Logs errors if invalid or already exists.
Parameters
category: Category
Returns void
registerContext
Registers a new context with its prerequisite. Contexts are sorted alphabetically by name after insertion. Logs errors if invalid or already exists.
Parameters
context: Context
Returns void
registerKeybinding
Registers a new keybinding. Validates category, contexts, and key combo. Automatically limits modifiers to a max of two.
Parameters
keybinding: Keybinding
Returns void
serialize
Serializes all current keybindings into Player.KeybindingSettings. Compresses using LZString.
Returns void
unregisterKeybinding
Removes a keybinding by action ID.
Parameters
actionId: string
Returns boolean
trueif deleted,falseif not found.
updateKeybinding
Updates the assigned key combo for a keybinding. Logs an error if readonly or not found.
Parameters
actionId: string
keyCombo: KeyCombo
Returns void
Initializes with default categories, contexts, and keybindings.