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

Plans for a useHotkeys hook?

Open jordantomax opened this issue 5 years ago • 6 comments

Is your feature request related to a problem? Please describe. I love that hooks make functional components possible for just about everything. I also love react-hotkeys because of its lack of dependencies and it's options to present active hotkeys information to the user.

Describe the solution you'd like Would love to get a useHotkeys option for react hotkeys.

Describe alternatives you've considered Looked into the existing https://github.com/JohannesKlauss/react-hotkeys-hook which is just a super simple wrapper around hotkeys-js library. Seems okay, but doesn't seem as well maintained and doesn't have the ability to present the user with a menu of registered hotkeys

Really just trying to gauge plans/interest to build such a feature.

jordantomax avatar Jul 18 '19 02:07 jordantomax

Hi @jordantomax,

I'd have to look into what's involved, but I'm open to the idea of supporting it. It seems to be the direction react is headed, so react-hotkeys should endeavour to support and remain consistent with that.

greena13 avatar Jul 18 '19 05:07 greena13

@greena13 - Any updates on this? I too would like to take advantage of hooks with this library!

amcdnl avatar Oct 16 '19 17:10 amcdnl

We need this.! This library needs update

softmarshmallow avatar Feb 11 '21 22:02 softmarshmallow

Would love to contribute to this. That would be amazing.

d-e-v-esh avatar Feb 12 '21 07:02 d-e-v-esh

I ended up writing my own library - https://github.com/reaviz/reakeys

amcdnl avatar Feb 12 '21 12:02 amcdnl

react-hotkeys-hook seems to be catching up:

Screenshot 2023-12-07 at 15 02 04

Download stats for react-hotkeys (🟢) decline quite quickly at the start of 2021. Does anyone know where all those downloads go? I wonder if there are any other alternatives worth exploring.


@jordantomax to your point on

[react-hotkeys-hook] doesn't have the ability to present the user with a menu of registered hotkeys

They seem to support this now via const { hotkeys } = useHotkeysContext();. You can provide descriptions to your hotkeys and then list them in some kind of a menu. The docs for this feature are missing though (https://github.com/JohannesKlauss/react-hotkeys-hook/issues/1104).

kachkaev avatar Dec 07 '23 14:12 kachkaev