jaywcjlove / hotkeys-js

➷ A robust Javascript library for capturing keyboard input. It has no dependencies.
https://jaywcjlove.github.io/hotkeys-js
MIT License
6.68k stars 411 forks source link

pause and resume functionality #215

Open aprilmintacpineda opened 4 years ago

aprilmintacpineda commented 4 years ago

hotkeys.pause() will stop listening to all hotkeys. hotkeys.resume() will start listening to all hotkeys if paused. If this method was called but not paused, then it should do nothing.

jaywcjlove commented 4 years ago

Realizing this requirement is easy, but is this okay?

aprilmintacpineda commented 4 years ago

Realizing this requirement is easy, but is this okay?

What do you mean "is this okay"?

For now, the workaround that I do is, I register all my hotkeys to myScope and then when I need to pause the hotkey for listening, I just do hotkeys.setScope('nonExistent'), but that means I will always have to put them on myScope but some of them should really be in all, which is always active. The use case for this is for customization, there will come a time when you allow the users to customize their shortcut keys, while they're setting that, I need hotkeys to be paused. Pause and resume should actually be a vital part of the library.

BTW, comments are in Chinese, I wanted to do a PR for this but can't understand the commend and don't wanna touch anything because I can see comments that I can't understand :(