matchesKeyCombo
projects/core/utils/keyboard.util.ts
Description#
Tests whether a KeyboardEvent matches a parsed KeyCombo.
A combo matches only a press carrying exactly the modifiers it names:
a bare 'b' matches an unmodified b and rejects Cmd+B, Ctrl+B,
Shift+B, Alt+B. mod resolves to the platform's primary modifier
(Meta on macOS, Ctrl elsewhere) and does not constrain the other one,
so 'mod+b' matches Cmd+B on macOS and Ctrl+B elsewhere. A
single-character punctuation key is shift-agnostic unless the combo names
shift, because the produced character already encodes the shift state
(? requires Shift on most layouts): '?' matches the Shift+/ press
that yields event.key === '?', while 'shift+?' still requires it and
ctrl/meta/alt stay strict for every key.
Events fired during IME composition (event.isComposing) never match -
keystrokes that build a composed character are text input, not shortcuts.