Angular 2 Keyboard Events

后端 未结 1 1067
既然无缘
既然无缘 2020-12-25 13:56

Trying to monitor keyboard events with Angular 2 using TypeScript and What is Angular2 way of creating global keyboard shortcuts (a.k.a. hotkeys)? was helpful but tslint (co

相关标签:
1条回答
  • 2020-12-25 14:18
    import {HostListener} from '@angular/core';
    
    @HostListener('window:keydown', ['$event'])
    handleKeyDown(event: KeyboardEvent) {
      // event.key === 'ArrowUp'
    }
    
    • @HostBindings('attr.foo') foo = 'bar' is to bind values from your component instance to the host element like class, attributes, properties or styles.
    0 讨论(0)
提交回复
热议问题