Angular 2 HostListener keypress detect escape key?

前端 未结 6 1126
温柔的废话
温柔的废话 2020-12-24 01:47

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

6条回答
  •  遥遥无期
    2020-12-24 02:25

    In my case (with Angular 10) keydown.escape works fine to track event escape by console.log():

    @HostListener('keydown.escape')
    fn() {
     console.log();
    }
    

    But Angular change detector work fine only with keyup.escape.

提交回复
热议问题