react-hotkeys-hook
react-hotkeys-hook copied to clipboard
Press `g` then `h` combination
Is your feature request related to a problem? Please describe. No
Describe the solution you'd like
Not sure if this already exists or not. I'm looking for a way to express a key sequence. In apps like Linear or Jira you can navigate using key combinations like g then h
. Unfortunately, I didn't find a way yet to achieve the same using react-hotkeys-hook.
Describe alternatives you've considered
The library react-hotkeys is able to do that using a string like 'g a'
Hi @ThisIsJustUs Yes, this is something I would like to add. But this might have to wait a bit, since I think a clean up of the code logic has a bigger priority for now.
Why not transition the event listenser to use Mousetrap for sequence?
Seems like it should be possible to work around this with useRecordHotkeys
, or maybe by storing some state in the callback of useHotkeys
.
I figured out an adhoc way of doing this, but it's not fully tested. Works good enough for what I need.
Here's the gist for the two files I changed. I made changes within the L89-L181 to manage a state with a setTimeout
. The validator now checks to see if the expected key is selected. I also included the modifier into the keys
to properly going through the sequence. Otherwise a ctrl+/
does not work.
Kudos to jamiebuilds / tinykeys for the sequence traversing.
This would be a cool feature. I was looking to implement a Konami code easter egg since I'm already using this package.
Would love this feature too!