JohannesKlauss / react-hotkeys-hook

React hook for using keyboard shortcuts in components.
https://react-hotkeys-hook.vercel.app/
MIT License
2.56k stars 112 forks source link

[BUG] isHotkeyPressed requires ALL buttons to be pressed, not just at least one #1165

Closed lexrama closed 2 months ago

lexrama commented 2 months ago

Describe the bug In the documentation for isHotkeyPressed, it says that if you pass an array of hotkeys in, the function will return true if at least one of the keys is pressed. However, the function only returns true if every hotkey is pressed.

I believe the issue is here, where the function is .every() where I believe it should be .some().

I might have misunderstood the API documentation though!

To Reproduce Steps to reproduce the behavior:

  1. Call isHotkeyPressed with an array of different hotkeys
  2. Press at least one, but not all, of the hotkeys. The function will return false instead of true.