react-use-hotkeys icon indicating copy to clipboard operation
react-use-hotkeys copied to clipboard

hotkeys using < or > not working

Open FranRioLorda opened this issue 2 years ago • 3 comments

I need to create a hotkeys as "option+<" and "option+shift+<", but they are not working.

FranRioLorda avatar Sep 27 '22 11:09 FranRioLorda

Hi @FranRioLorda. The combination 'option+<' ('Alt+<') results in the following event.key value: . If you would like to create a modifier combo to achieve what you want, you can do 'Alt+,', which from a users perspective involves pressing option/alt and the < key. You can get the event.key value for a given keyboard press using this tool: https://www.toptal.com/developers/keycode.

Let me know if this helps, or if I've misunderstood 😄

reecelucas avatar Sep 27 '22 12:09 reecelucas

Hi @reecelucas!. First of all, thank you very much by your ultra fast response and your time! I'm going to put more context, cause I think that was me who didn't explain very well! I've created a hotkey using useHotKeys with "option+<", an it does not work. I've tried your solution, with "Alt+<" and "≤" and "≥" to no avail. I have many other hotkeys in the app using your great hook without any problems at all!

FranRioLorda avatar Sep 27 '22 13:09 FranRioLorda

Ah, I see, this is because the Alt key changes the event.key value, so using "Alt+," results in the event.key, but the logic for modifier combinations doesn't handle this. It's a tricky one, but I'll look into a solution. In the meantime you might be able to use the escape hatch to provide a workaround this limitation for the time being.

reecelucas avatar Sep 27 '22 17:09 reecelucas