import { RefObject } from 'react'; export type HotkeyHandler = (event: KeyboardEvent) => void; /** Combo → handler, e.g. `{ 'mod+k': open, Escape: close }`. */ export type HotkeyMap = Record; export interface UseHotkeysOptions { /** Attach the listener at all. Default `true`; pass `false` to suspend every combo at once. */ enabled?: boolean; /** Scope the shortcuts to one element instead of the whole window. */ target?: RefObject; /** * Let plain-key combos fire while a text field or `contenteditable` has focus. Default `false`, * so `'n'` does not fire for every `n` typed into an input. Combos carrying Ctrl, Cmd or Alt * are never suppressed — they cannot be confused with typing. */ enableInFields?: boolean; /** * Call `preventDefault()` on a match, so `mod+s` does not also open the browser's save dialog. * Default `true`. */ preventDefault?: boolean; /** * Fire again for each repeat while the combo is held. Default `false`, so holding `mod+s` saves * once. Turn it on for keys that step through something, such as arrows or zoom. */ repeat?: boolean; } /** * A combo written for the reader: `'mod+shift+k'` reads `⇧⌘K` on an Apple platform and * `Ctrl+Shift+K` everywhere else. * * So a shortcut is written once, in one spelling, and the hint beside it cannot contradict what * the binding actually listens for. Hand-written `'⌘K'` hints are wrong on every other platform, * silently, because nothing compares the label to the binding. * * Resolved from the platform at call time, so a server-rendered page renders the non-Apple form. */ export declare function formatHotkey(combo: string): string; /** * A combo as `aria-keyshortcuts` spells it: `'mod+shift+k'` is `Control+Shift+K`, or * `Meta+Shift+K` on an Apple platform. Resolved from the platform like `formatHotkey`, so the two * always name the same keys. */ export declare function ariaKeyshortcuts(combo: string | undefined): string | undefined; /** * Keyboard shortcuts, for a whole app or for one element. * * ```tsx * useHotkeys({ 'mod+k': () => setPaletteOpen(true), '?': () => setHelpOpen(true) }); * ``` * * The map is read through a ref at event time, so an inline object literal is fine and no handler * needs memoising. Shortcuts keep firing while a Modal or Drawer is open — pass `enabled` for the * ones that should not. */ export declare function useHotkeys(hotkeys: HotkeyMap, options?: UseHotkeysOptions): void; export default useHotkeys;