/** * Keyboard chords: matching, platform notation and desktop accelerators. * * A chord always has ⌘ (Mac) or Ctrl (Windows and Linux) unless it is a * navigation chord with ⌥/Alt, so it never fights with typing. Chords match on * `KeyboardEvent.code`, which names the physical key, so they work on every * keyboard layout. Punctuation also matches the character typed, because many * layouts put it elsewhere: "/" is ⇧7 on Nordic and German keyboards. */ export type ChordPlatform = "mac" | "other"; export type ActionSurface = "web" | "desktop"; export type Chord = { /** `KeyboardEvent.code`, e.g. `"KeyO"`, `"Comma"`, `"ArrowDown"`, `"Digit1"`. */ code: string; /** ⌘ on Mac, Ctrl elsewhere. */ mod?: boolean; shift?: boolean; /** ⌥ on Mac, Alt elsewhere. */ alt?: boolean; /** The Control key itself on Mac (⌃). Ignored elsewhere, where `mod` is Ctrl. */ control?: boolean; /** Only on this surface (browsers reserve some keys). */ only?: ActionSurface; /** Only on this platform. */ platform?: ChordPlatform; /** * A text-formatting key (⌘B is bold): rich-text editors keep it, so the page * handles it and the desktop menu bar never owns it. */ formatting?: boolean; }; export declare function currentPlatform(): ChordPlatform; /** The chords that apply on this surface and platform, in priority order. */ export declare function applicableChords(chords: readonly Chord[] | undefined, surface: ActionSurface, platform: ChordPlatform): Chord[]; export declare function matchesChord(event: Pick & Partial>, chord: Chord, platform: ChordPlatform): boolean; /** The chord as keycaps, in the platform's own notation: `["⌘", "⇧", "O"]` or `["Ctrl", "Shift", "O"]`. */ export declare function chordKeys(chord: Chord, platform: ChordPlatform): string[]; /** One string for tooltips and `title`s: `⌘⇧O` on Mac, `Ctrl+Shift+O` elsewhere. */ export declare function chordLabel(chord: Chord, platform: ChordPlatform): string; /** The `aria-keyshortcuts` value for a chord. */ export declare function chordAriaKeys(chord: Chord, platform: ChordPlatform): string; /** An Electron accelerator for the desktop menu bar. */ export declare function chordAccelerator(chord: Chord): string; /** True when typing into this element would insert text (so bare keys belong to it). */ export declare function isTextEntry(target: EventTarget | null): boolean;