import { FormatHotkeyOptions } from './format.mjs'; import { HotkeyTarget } from './types.mjs'; interface RecordedHotkey { /** * The raw hotkey string (e.g., "Control+Shift+K" or "G > H") */ value: string; /** * The platform-formatted display string (e.g., "⌃⇧K" on Mac) */ display: string; } interface HotkeyRecorderOptions { /** * The target element to listen for key events */ target?: HotkeyTarget | undefined; /** * Called when a hotkey is successfully recorded */ onRecord?: (hotkey: RecordedHotkey) => void; /** * Called when recording is cancelled (via Escape) */ onCancel?: () => void; /** * Called when the recorded hotkey is cleared (via Backspace/Delete) */ onClear?: () => void; /** * Options for formatting the display string */ formatOptions?: FormatHotkeyOptions | undefined; /** * Timeout in milliseconds to wait for the next sequence step. * If no key is pressed within this window, the recording finalizes. * @default 1000 */ sequenceTimeoutMs?: number | undefined; } interface HotkeyRecorderState { /** * Whether the recorder is currently listening for key events */ recording: boolean; /** * The current recorded hotkey, or null if nothing recorded. * Updates live as steps are added (e.g., "G" then "G > H"). */ value: RecordedHotkey | null; } type RecorderSubscriber = (state: HotkeyRecorderState) => void; declare class HotkeyRecorder { private state; private target?; private options; private platform; private keyDownHandler?; private keyUpHandler?; private subscribers; private steps; private sequenceTimerId?; private previousValue; constructor(options?: HotkeyRecorderOptions); /** * Initialize the recorder with a target DOM element. * Must be called before `start()` if target was not provided in options. */ init(target: HotkeyTarget): this; /** * Start recording. Captures key combinations, automatically detecting sequences. */ start(): this; /** * Stop recording without changing the current value. */ stop(): this; /** * Cancel recording. Stops recording and invokes onCancel. */ cancel(): this; /** * Clear the recorded hotkey and stop recording. */ clear(): this; /** * Update options (callbacks, formatOptions) without recreating the recorder. * Useful for keeping callbacks in sync with component state. */ setOptions(options: Partial): this; /** * Get the current recorder state. */ getState(): Readonly; /** * Subscribe to state changes. */ subscribe(callback: RecorderSubscriber): () => void; /** * Clean up all listeners and subscriptions. */ destroy(): void; private setState; private attachListeners; private detachListeners; private handleKeyDown; private buildRecordedHotkey; private finalize; private clearSequenceTimer; } declare function createHotkeyRecorder(options?: HotkeyRecorderOptions): HotkeyRecorder; export { HotkeyRecorder, type HotkeyRecorderOptions, type HotkeyRecorderState, type RecordedHotkey, createHotkeyRecorder };