import { wrIsPrintableKey } from 'ngwr/utils';
// Type-to-search: ignore arrows, Enter and chords.
@HostListener('keydown', ['$event']) onKey(e: KeyboardEvent) {
if (wrIsPrintableKey(e)) buffer.push(e.key);
}wrIsPrintableKey
True for a single printable character typed without Ctrl, Cmd or Alt (Shift is allowed).
Usage
Do not guard with wrHasModifier first: it counts Shift, so capitals would never arrive.
API
| Name | Description | Type | Default |
|---|---|---|---|
wrIsPrintableKey(event) | True for a single printable character with no Ctrl, Cmd or Alt held. Shift is accepted, so capitals arrive. | (e: KeyboardEvent) => boolean | — |
See also
Guide KeyboardBind shortcuts, show them as keycaps, and see which keys each component handles.Util wrHasModifierTrue when Ctrl, Cmd, Alt, Shift or Meta is held during a KeyboardEvent.Util WR_KEYSKeyboardEvent.key constants, the WrKey union of their values, and WR_KEY_LABELS, what each key is called on a keycap.Util wrIsComposingTrue while an input method (IME) is composing, so the key belongs to it and not to your handler.