Primitives / foldkit-primitives/events

matchHotkey

function · packages/primitives/src/events/hotkeys.ts:53

function matchHotkey(pattern: string, press: KeyPress): boolean

Hotkey matching as a pure function over a Pressed payload: matchHotkey answers whether a press is the shortcut, so update stays a table of chords instead of a nest of modifier checks. Patterns read like "ctrl+shift+k": modifiers first (any order), the key last, case-insensitive, with cmd/command and option as the Mac names for meta and alt. Matching is exact — unlisted modifiers must be up — and auto-repeat never matches, so holding a chord fires once. space (or a bare space) means the space key; esc means escape. A pattern with no key, or two keys, matches nothing: predicates return false, they do not throw on the hot path.