JohannesKlauss / react-hotkeys-hook

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

[BUG] After upgrading to 4.4.3 some shortcuts stopped working #1110

Closed damusnet closed 6 months ago

damusnet commented 6 months ago

Describe the bug shit+? and shift+plus,shift+bracketright used to work, now they don't

To Reproduce Steps to reproduce the behavior:

  1. Go to CodeSandbox repro
  2. Make sure to open the console
  3. Try hitting shift+?, shift+plus, shift+minus (with + and - keys respectively)
  4. Only shift+minus will log to the console

Expected behavior Existing shortcuts should still work

Screenshots

image

Desktop (please complete the following information):

rawpixel-vincent commented 6 months ago

same here, commenting out that line:

 // if (!(keys != null && keys.includes(keyCode)) && !['ctrl', 'control', 'unknown', 'meta', 'alt', 'shift', 'os'].includes(keyCode)) {
  //   console.log("elmoo");
  //   return false;
  // }

in isHotkeyMatchingKeyboardEvent() fix the issue, if that helps

happens is firefox / chrome - linux and macos

I've managed to log that before this condition execute, and I'm not sure why "right" is in keys, maybe some memoization issue 🤷🏻 {"pressedKey":"delete","keyCode":"","keys":["right"]}

downgrading to 4.4.1 fixed the issue, all good 👍🏻

JohannesKlauss commented 6 months ago

Hmh, weird. I'll have a look into it.

JohannesKlauss commented 6 months ago

Weirdly enough only Shift+? works for me, the other two don't register.

JohannesKlauss commented 6 months ago

Fixed in 4.4.4

damusnet commented 6 months ago

Thank you for looking into this.

After updating the CodeSandbox to 4.4.4: shift+? and shift+minus now both work, but shift+plus still doesn't.

Note also that on a extended keyboard with separate numpad, neither shift+plus nor shift+minus work.