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] Events with similar keys get triggered #1218

Open
eportet opened this issue Oct 31, 2024 · 0 comments
Open

[BUG] Events with similar keys get triggered #1218

eportet opened this issue Oct 31, 2024 · 0 comments

Comments

@eportet
Copy link

eportet commented Oct 31, 2024

If you add a shortcut d that triggers action A and shortcut g+d that triggers action B.

  useHotkeys("d", A);
  useHotkeys("g+d", B);

Pressing d only triggers action A. But if you press g+d both action A and B get triggered.

I would expect this behavior if I had inverted the first shortcut to d+g since there is a time where I am pressing solely the d key and therefore I would expect action A to get triggered.

But I don't see why the library wouldn't be able to tell that when I am pressing key g and d at the same time the action that should be triggered is that of g+d/ action B.

Repro

I created a reproduction sandbox with some other shortcuts that also don't work as you would expect.

https://codesandbox.io/s/react-hotkeys-firing-events-with-same-key-t3kdqq

I also tried playing with the new useKey property in v5 but that didn't fix the issue.

Related issues

I've checked out #1005 and I initially thought this would be tied to the order of the keys not mattering, but decided to create it's own issue.

EDIT: I am now just seeing #677 which I think is this exact same issue. Happy to close this in favor of that issue.

Solution

For now I'm just changing which shortcuts I use.

But if this is something that could be addressed I would be happy to help making a PR.

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

1 participant