react-hotkeys-hook icon indicating copy to clipboard operation
react-hotkeys-hook copied to clipboard

Press `g` then `h` combination

Open ThisIsJustUs opened this issue 1 year ago • 6 comments

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'

ThisIsJustUs avatar Mar 23 '23 17:03 ThisIsJustUs

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.

JohannesKlauss avatar Mar 24 '23 08:03 JohannesKlauss

Why not transition the event listenser to use Mousetrap for sequence?

The-Podsiadly avatar Sep 10 '23 15:09 The-Podsiadly

Seems like it should be possible to work around this with useRecordHotkeys, or maybe by storing some state in the callback of useHotkeys.

alexgleason avatar Sep 14 '23 18:09 alexgleason

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.

The-Podsiadly avatar Sep 14 '23 18:09 The-Podsiadly

This would be a cool feature. I was looking to implement a Konami code easter egg since I'm already using this package.

strafe avatar Mar 16 '24 23:03 strafe

Would love this feature too!

pondorasti avatar Apr 24 '24 01:04 pondorasti