type HotkeyTarget = Document | ShadowRoot | Element; type HotkeyCommandTarget = HotkeyTarget | (() => HotkeyTarget | null); type Platform = "mac" | "windows" | "linux"; interface KeyboardModifiers { alt?: boolean | undefined; ctrl?: boolean | undefined; meta?: boolean | undefined; shift?: boolean | undefined; } interface SequenceStep extends KeyboardModifiers { key: string; } interface ParsedHotkey extends KeyboardModifiers { keys: string[]; codes?: string[] | undefined; isSequence?: boolean | undefined; description?: string | undefined; sequenceSteps?: SequenceStep[] | undefined; } type HotkeyAction = (event: KeyboardEvent) => void; interface CommandDefinition { /** * The unique identifier for the command. */ id: string; /** * The hotkey to trigger the command. */ hotkey: string; /** * The action to perform when the hotkey is triggered. */ action: HotkeyAction; /** * Human-readable label for the command */ label?: string | undefined; /** * Description of what the command does */ description?: string | undefined; /** * Category for organizing commands */ category?: string | undefined; /** * Options for the hotkey command. */ options?: HotkeyOptions | undefined; /** * Whether the command is enabled. */ enabled?: boolean | (() => boolean) | undefined; /** * The scopes to use for the hotkey command. * * @default "*" */ scopes?: string | string[] | undefined; /** * Keywords for search/command palette integration. * Useful for alternative names or search terms for the command. */ keywords?: string[] | undefined; } interface HotkeyCommand { id: string; hotkey: string; action: HotkeyAction; label?: string | undefined; description?: string | undefined; category?: string | undefined; options: HotkeyOptions; enabled: boolean | (() => boolean); scopes: string[]; keywords: string[]; _parsed: ParsedHotkey; _priority: number; _registrationOrder: number; } type ConflictBehavior = "warn" | "error" | "replace" | "allow"; interface HotkeyStoreOptions { /** * The target element to listen for hotkeys */ target?: HotkeyTarget | undefined; /** * The default options to use for the store */ defaultOptions?: Partial | undefined; /** * The timeout in milliseconds for sequence completion * @default 1000 */ sequenceTimeoutMs?: number | undefined; /** * The active scopes when the store is created * @default ["*"] */ activeScopes?: string | string[] | undefined; /** * How to handle conflicts when two commands register the same hotkey. * @see ConflictBehavior * - `"warn"`: Log a warning but allow both (default) * - `"error"`: Throw an error preventing registration * - `"replace"`: Unregister the existing command * - `"allow"`: Silently allow duplicates * @default "warn" */ conflictBehavior?: ConflictBehavior | undefined; } type FormTagName = "input" | "textarea" | "select"; interface HotkeyOptions { /** * Whether to prevent the default browser behavior. * */ preventDefault?: boolean | undefined; /** * Whether to stop the event propagation */ stopPropagation?: boolean | undefined; /** * Whether to enable the hotkey on form tags. * - `true`: Enable on all form tags (input, textarea, select) * - `false`: Disable on all form tags (default) * - `FormTagName[]`: Enable only on specific form tag types */ enableOnFormTags?: boolean | FormTagName[] | undefined; /** * Whether to enable the hotkey on content editable elements. */ enableOnContentEditable?: boolean | undefined; /** * Use capture phase for event listeners (default: true) */ capture?: boolean | undefined; /** * When true, the hotkey fires only once per key press. * The key must be released before it can fire again. * @default false */ requireReset?: boolean | undefined; /** * The event type to listen for. * - `"keydown"`: Fire when the key is pressed (default) * - `"keyup"`: Fire when the key is released * @default "keydown" */ eventType?: "keydown" | "keyup" | undefined; /** * Scope the command to a DOM subtree. The command only fires when the event * originates within this element. Accepts an element or a function returning * one, resolved on every event; while it resolves to `null`, the command is * skipped. The element must contain focus to receive keyboard events. */ target?: HotkeyCommandTarget | undefined; } interface HotkeyStoreState { pressedKeys: Set; /** Physical `KeyboardEvent.code` values currently held (mirrors `matchesHotkey` code path). */ pressedCodes: Set; commands: Map; listening: boolean; activeScopes: Set; } export type { CommandDefinition, ConflictBehavior, FormTagName, HotkeyAction, HotkeyCommand, HotkeyCommandTarget, HotkeyOptions, HotkeyStoreOptions, HotkeyStoreState, HotkeyTarget, KeyboardModifiers, ParsedHotkey, Platform, SequenceStep };