我正在开发一个Angular2项目,我想在其中加入各种功能的快捷键。
我对两种方法感到困惑。一种是使用HostListener创建快捷方式,如下所示:
@HostListener('document:keydown', ['$event'])
handleHotkey(event: KeyboardEvent){
...
}
另一种方法是使用Mousetrap JS框架,然后围绕它创建一个服务,这个服务是根据我angular2-hotkeys中的项目自定义的。
根据我的说法,在Hostlistener上使用Mousetrap -
这对于angular2来说是更好的方法。
我特别关注性能下降。