Exposing recordedKeys for rendering active key states #1295
lewisl9029
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey Johannes, really appreciate your work on the library, been using it as part of a new hotkeys system and really enjoying it so far! :)
One thing I wanted to do is render the hotkeys in an active state as they're pressed in part of a sequence to give users some visual feedback. Here's what this might look like in practice:
I don't think this is possible with the current version of the library, but I did come up with a fairly small changeset that enables it, by turning
recordedKeysinto React state and exposing it as part of the hook output. I have it in a WIP branch here that I've published to https://www.npmjs.com/package/@lewisl9029/react-hotkeys-hook if anyone wants to give it a shot.A few notes on the implementation:
exposeRecordedKeys, both for backwards compatibility, and for performance, since enabling this would cause rerendering whenever recordedKeys updates, which could result in perf regressions.{ scopeRef, recordedKeys }). So will need a major version bump.Would you be interested in a PR to integrate this into the library? Would be more than happy to upstream it and help update the docs and whatnot. But also would be happy to keep it in my fork for now if you don't think it belongs here.
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions