ChemPal Documentation - v1.7.0
    Preparing search index...

    Module hotkeys

    Enumerations

    HotkeyEvent

    Custom DOM event names used to bridge global hotkey handlers in App.tsx to components that own the relevant local state (e.g. ResultsTable).

    Functions

    HotkeyHelpModal
    isMac

    Detects whether the current platform is macOS. Used to expand the mod token and to select the mac branch of a platform-aware KeyBinding. Falls back to navigator.platform for broad compatibility; the newer userAgentData API is preferred when available.

    resolveBinding

    Resolves a platform-aware KeyBinding down to a single string for the current platform. Pass-through when already a string.

    parseBinding

    Parses a key-binding string such as "mod+shift+r" into a ParsedBinding. The final +-separated token is treated as the key; earlier tokens are modifiers. The mod token expands to meta on macOS and ctrl elsewhere.

    matches

    Checks whether a KeyboardEvent matches a ParsedBinding. Matching is strict on modifiers — any modifier that is not required in the binding must not be held down, so ctrl+s will not also fire for ctrl+shift+s. Key comparison is case-insensitive via event.key.

    normalizeKey

    Normalizes a single binding token (e.g. "UpArrow", "Esc", "A") to the lowercased KeyboardEvent.key value it should match. Unknown tokens map to their own lowercased form.

    parseSequence

    Parses a sequential binding string such as "up+up+down+down+left+right" into an ordered array of normalized keys. Unlike parseBinding, every token is a key in the sequence — there are no modifiers.

    formatSequenceTokens

    Formats a sequential binding into per-step display labels for the help modal — arrows become ↑ ↓ ← →, named keys are title-cased, and single characters are upper-cased.

    formatBinding

    Formats a key-binding string into a human-readable label for display in the help modal. Uses platform-appropriate symbols (⌘ ⌥ ⌃ ⇧) on macOS and spelled-out names (Ctrl, Alt, Shift) elsewhere.

    useHotkeys
    getHotkeyConfigs

    Returns the raw list of hotkey configs loaded from config.json. Useful for the help modal or any UI that needs to enumerate the bindings.

    Interfaces

    HotkeyConfig

    A single hotkey entry as loaded from config.json. id is the logical action name that is resolved at runtime against a handler registry.

    ParsedBinding

    Parsed representation of a key binding that can be matched against a KeyboardEvent. Modifier flags are strict: a modifier set to false must NOT be pressed (so ctrl+s does not also fire ctrl+shift+s).

    Modules

    <internal>

    Type Aliases

    KeyBinding

    A platform-aware key binding. Either a single string shared across platforms, or an object with separate mac / other bindings.

    HotkeyHandlers

    Map of hotkey action id → handler function. Used by useHotkeys. A handler may return a promise; errors are logged but not thrown.