greena13 / react-hotkeys

Declarative hotkey and focus area management for React
https://github.com/greena13/react-hotkeys
ISC License
2.15k stars 160 forks source link

Plans for a useHotkeys hook? #210

Open jordantomax opened 5 years ago

jordantomax commented 5 years ago

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.

greena13 commented 5 years ago

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.

amcdnl commented 5 years ago

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

softmarshmallow commented 3 years ago

We need this.! This library needs update

d-e-v-esh commented 3 years ago

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

amcdnl commented 3 years ago

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

kachkaev commented 10 months ago

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).