What is Angular2 way of creating global keyboard shortcuts (a.k.a. hotkeys)?

后端 未结 3 2005
花落未央
花落未央 2020-12-29 20:06

What would be proper way of creating global keyboard shortcuts (a.k.a. hotkeys) in Angular2 application?

Let\'s say good starting point would be to get working: \"?

3条回答
  •  Happy的楠姐
    2020-12-29 20:53

    You can use a library I created called angular2-hotkeys

    It lets you create hotkeys like this:

    constructor(private _hotkeysService: HotkeysService) {
      this._hotkeysService.add(new Hotkey('meta+shift+g', (event: KeyboardEvent) => {
        console.log('Typed hotkey');
        return false; // Prevent bubbling
    }));  }
    

提交回复
热议问题