angular2-hotkeys icon indicating copy to clipboard operation
angular2-hotkeys copied to clipboard

Hotkeys being fired when cheatsheet is shown

Open AshMcConnell opened this issue 7 years ago • 2 comments

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!

AshMcConnell avatar Mar 09 '18 09:03 AshMcConnell

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;
    }
  }

AshMcConnell avatar Mar 22 '18 14:03 AshMcConnell

Thanks for the report. I'll look into fixing this in the bundled cheat sheet.

wittlock avatar Mar 28 '18 21:03 wittlock