import { KEYS, type WrKey } from 'ngwr/utils';
if (event.key === KEYS.ESCAPE) {
close();
}
function onArrow(key: WrKey) { /* … */ }KEYS
KeyboardEvent.key constants, plus the WrKey union of their values.
Usage
API
| Name | Description | Type | Default |
|---|---|---|---|
KEYS | KeyboardEvent.key values: ENTER, ESCAPE, ARROW_UP, ARROW_DOWN, TAB, SPACE, … | const record | — |
WrKey | Union of every value in KEYS, for typed key parameters. | type alias | — |
See also
Guide KeyboardBind shortcuts, show them as keycaps, and see which keys each component handles.Service WrHotkeyFor whole chords.Util hasModifierTrue when Ctrl, Cmd, Alt, Shift or Meta is held during a KeyboardEvent.Util isPrintableKeyTrue for a single printable character typed without Ctrl, Cmd or Alt (Shift is allowed).Util isComposingTrue while an input method (IME) is composing, so the key belongs to it and not to your handler.