I am working on an Angular2 project wherein I want to incorporate Shortcut keys for various functionalities.
I am confused between two approaches. One is to create shortcuts by using HostListener as below :
@HostListener('document:keydown', ['$event'])
handleHotkey(event: KeyboardEvent){
...
}
The other approach is to use Mousetrap JS framework and then create a service around it which is customized to my project as done in angular2-hotkeys.
Some Pros according to me of using Mousetrap over Hostlistener -
- A common service to add/remove/pause/unpause shortcuts.
- Reading of hotkeys from a config file.
- Ease of coding and maintenance.
Which would be a better approach for angular2.
I am especially concerned about degraded performance.