react-hotkeys-hook
react-hotkeys-hook copied to clipboard
[BUG] Hotkeys for 'z' and 'y' not working correctly when using ISO keyboard layout
Describe the bug It doesn't matter if I press 'y' or 'z' on my keyboard. The callbacks for both keys are triggered.
To Reproduce Steps to reproduce the behavior:
useHotkeys(['ctrl+z', 'z'], (keys) => console.log(keys)); useHotkeys(['ctrl+y', 'y'], (keys) => console.log(keys));
Expected behavior A clear and concise description of what you expected to happen. if I press 'y' than only y the callback of y should be triggered. The same for z
Desktop (please complete the following information):
- OS: MacOS Ventura 13.4
- Browser chrome
- Version 114.0.5735.133
Yes, this is related to this issue. I am working on a version 5 that only listens to the produced key. But I am super busy right now, so this might take some time.
Yes, this is related to this issue. I am working on a version 5 that only listens to the produced key. But I am super busy right now, so this might take some time.
I'm not sure if this is related, but it doesn't look like the "esc" or "escape" key is firing an event when bound.
I ran into the same issue. You can check the first argument of the callback for the key which always seems to have the correct key that is pressed.
After pressing ctrl+z, the following event handler fires :grimacing:
useHotkeys(
['ctrl+y, command+y'],
({ key, ...rest }, handler) => {
if (key === 'z') {
return
}
// Now handle the actual ctrl+y event but beware: handler.keys === ['z']
}
)
This is quite a big bug imo, would there be any way to patch it within v4?
This would be a breaking change, so it's not feasible to fix it in version 4, sorry.
This is a layout specific problem that gets addressed in version 5.
This has been fixed in pre release 5.0.0-1. Please try out this version.
To listen to y use you just use useHotkeys('y', callback, {useKey: true})
Please let me know if that fixes your issue.