angular2-hotkeys
angular2-hotkeys copied to clipboard
Hotkeys being fired when cheatsheet is shown
Thanks for a great lib, it's very useful indeed, but I have a tiny snag.
Is there any way to prevent the hotkeys being fired when the cheatsheet is shown? I press m for menu and I can see it behind the cheatsheet. Even closing the cheatsheet when a hotkey is pressed would do.
Any ideas? Thanks!
I fixed this by creating my own cheatsheet and modifying the toggleCheatSheet function like so: -
public toggleCheatSheet(): void {
this.helpVisible = !this.helpVisible;
if (!this.helpVisible) {
this.unpauseHotkeys();
} else {
this.pauseHotkeys();
}
}
private pauseHotkeys() {
const hotkeysToPause = this.hotkeys.filter(hotkey => hotkey.combo[0] !== '?' && hotkey.combo[0] !== 'esc');
this.hotkeysService.pause(hotkeysToPause);
this.pausedHotkeys = hotkeysToPause;
}
private unpauseHotkeys() {
if (this.pausedHotkeys) {
this.hotkeysService.unpause(this.pausedHotkeys);
this.pausedHotkeys = null;
}
}
Thanks for the report. I'll look into fixing this in the bundled cheat sheet.