I am using the following method to detect keypresses on a page. My plan is to detect when the Escape key is pressed and run a method if so. For the moment I am just attempti
event.key == "Escape"
The old alternatives (.keyCode and .which) are Deprecated.
.keyCode
.which
@HostListener('document:keydown', ['$event']) onKeydownHandler(event: KeyboardEvent) { if (event.key === "Escape") { // Do things } }