Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isHotkeyPressed not working when not using useHotKeys anywhere #766

Closed
nddery opened this issue Jun 10, 2022 · 3 comments
Closed

isHotkeyPressed not working when not using useHotKeys anywhere #766

nddery opened this issue Jun 10, 2022 · 3 comments

Comments

@nddery
Copy link

nddery commented Jun 10, 2022

Seems like isHotKeyPressed always return false when useHotKeys isn't used elsewhere in the app.

Holding shift and clicking the button does not increment the count: https://codesandbox.io/s/prod-glitter-x5fxiw?file=/src/App.js

Same sandbox, but if I invoke useHotKeys, holding shift and clicking the button does increment the count: https://codesandbox.io/s/wizardly-sun-1ns9sz?file=/src/App.js

@nddery
Copy link
Author

nddery commented Jun 10, 2022

Seems like when using hotkeys-js directly, you need to wrap any calls to hotkeys.isPressed inside hotkeys() - hence I think the behavior showcased in the codesandbox above is expected.

However, seems like useHotKeys does have some side effects, which caught me off guard, thinking something was wrong.

I'd imagine the number of people using this library without using useHotKeys to be quite small, as at this point you're better off using hotkeys-js directly.

@JohannesKlauss
Copy link
Owner

This seems to be related to #765
Starting at version 4 we will drop the hotkeys-js package and rely on our own solution. isHotkeysPressed will then work independently from the hook. Although we haven't implemented that feature yet, I am confident that we will have it working as we intended it.
Version 4 will hopefully have its first release candidate in the next few weeks.

@JohannesKlauss
Copy link
Owner

This is fixed with version 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants