UtilUpdated in v16Optional

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.

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);
}

API

NameDescriptionTypeDefault
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