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
}));
}Or even multiple hotkeys for the same callback like this:
this._hotkeysService.add(new Hotkey(['meta+shift+g', 'alt+shift+s'], (event: KeyboardEvent, combo: string) => {
console.log('Combo: ' + combo); // 'Combo: meta+shift+g' or 'Combo: alt+shift+s'
return false; // Prevent bubbling
}));