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

[BUG] Hotkeys for 'z' and 'y' not working correctly when using ISO keyboard layout #1040

Open
EricBlommel opened this issue Jun 20, 2023 · 5 comments
Labels
bug Something isn't working Version 5.x These tickets will be solved in Version 5.x

Comments

@EricBlommel
Copy link

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
@JohannesKlauss
Copy link
Owner

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.

@JohannesKlauss JohannesKlauss added Version 5.x These tickets will be solved in Version 5.x bug Something isn't working labels Jun 23, 2023
@clickar14
Copy link

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.

@CodingDive
Copy link

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 😬

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?

@JohannesKlauss
Copy link
Owner

This would be a breaking change, so it's not feasible to fix it in version 4, sorry.

@JohannesKlauss
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Version 5.x These tickets will be solved in Version 5.x
Projects
None yet
Development

No branches or pull requests

4 participants