omridevk / ng-keyboard-shortcuts

Dead Simple Keyboard Shortcuts Management for Angular
https://ng-keyboard-shortcuts.vercel.app/
147 stars 34 forks source link

Reducing the time to react to key shortcuts ? #164

Open NSiggel opened 1 year ago

NSiggel commented 1 year ago

Currently trying to reduce the amount of time is takes for the keyboard shortcut to be activated, function to execute.

I've seen reference to debounce time, and looking at the interfaces seeing throttleTime, however I don't seem to be able to tweak the timing, to bring it down to the near instant timing you have in your demo for the help-menu (-->ng-keyboard-shortcuts-help).

https://codesandbox.io/s/yvyovny43v?fontsize=14&hidenavigation=1&theme=dark Specifically In your Demo, the F1 Key is almost instantaneous. Help menu pop open instantly.

<ng-keyboard-shortcuts [shortcuts]="shortcuts"> <ng-keyboard-shortcuts-help [key]="'f1'" [closeKey]="'escape'" [title]="'Help'">

Other keybinding take a little time to react, I'm guessing this is part of Sequence detection.

I would like to bind other keys to have that near instant function call, instead of waiting for x amount of time before it kicks in. I tried adding something like { key: "f2", throttleTime: 10, label: "Filter", description: "Sort By", command: (e) => console.log("wow.. sort by...", { e }), preventDefault: false }, I'm currently testing this with usage off a StreamDeck, so binding to some other Function keys or combinations in order to activate specific functions in our web app, but the delay is causing confusion.

Any suggestions ? documentation on getting the key definitions to be as reactive as the F1 for the help menu ?