/** * Keyboard shortcut specs — pure parsing, display and matching (no DOM). * * A spec is `modifier+…+key`, case-insensitive: `alt+q`, `shift+alt+s`, `mod+enter`. * Modifiers: `ctrl`/`control`, `alt`/`option`, `shift`, `meta`/`cmd`/`command`, and * `mod` (⌘ on Mac, Ctrl elsewhere). The key is one letter, digit, punctuation mark, * or a named key (`enter`, `escape`, `space`, `tab`, `backspace`, `delete`, * `arrowup`…, `home`, `end`, `pageup`, `pagedown`, `f1`…`f12`). * * Letters, digits and punctuation match by PHYSICAL key (`KeyboardEvent.code`), so * ⌥Q on a Mac (which types "œ") and a Thai layout (which types "ๆ") still match `alt+q`. * Named keys match by `KeyboardEvent.key`. */ export interface ParsedShortcut { /** Lower-cased key token: `q`, `1`, `/`, `enter`, `f2`. */ key: string; ctrl: boolean; alt: boolean; shift: boolean; meta: boolean; /** ⌘ on Mac, Ctrl elsewhere — resolved at match/format time. */ mod: boolean; } /** The slice of `KeyboardEvent` matching reads; plain objects work too. */ export interface ShortcutKeyEvent { key: string; code: string; altKey: boolean; ctrlKey: boolean; metaKey: boolean; shiftKey: boolean; } export interface ShortcutPlatform { /** Apple platform: `mod` = ⌘ and display uses ⌃⌥⇧⌘ glyphs. */ mac: boolean; } /** Parse a spec; `null` when it has no key, two keys, or an unknown token. */ export declare function parseShortcut(spec: string): ParsedShortcut | null; /** Display text: `⌥⇧S` on Mac (⌃⌥⇧⌘ order), `Alt+Shift+S` elsewhere; `''` if unparseable. */ export declare function formatShortcut(spec: string, { mac }: ShortcutPlatform): string; /** Value for `aria-keyshortcuts` (`Alt+Shift+S`, `Control+S`, `Meta+Enter`); `''` if unparseable. */ export declare function ariaKeyshortcuts(spec: string, { mac }: ShortcutPlatform): string; /** True when the event is exactly this shortcut (same modifier set, same key). */ export declare function matchShortcut(e: ShortcutKeyEvent, spec: string | ParsedShortcut, { mac }: ShortcutPlatform): boolean;