-
Notifications
You must be signed in to change notification settings - Fork 118
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
slash, backslash, and bracketright are not defined correctly in parseHotkeys.ts #1125
Comments
I have a similar issue with the '-': 'slash' key where it doesn't trigger the expected behaviour as in earlier versions. Could you please take a look at this issue? Thanks |
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. Please let me know if that fixes your issue. |
Not the OP, but it fixes the "/" slash for me; thank you very much! |
Hi @JohannesKlauss I recently update to version To be clear and have a use case for you to reproduce it, I selected the key |
This is the way to use special characters that are different on different layouts: https://codesandbox.io/p/sandbox/lucid-ioana-c8zjcj Please let me know if that works for you. |
@JohannesKlauss Is what I did, but even in your sandbox I see the same issue as I have. Perhaps I didn't explain myself correctly, what I want is that no matter the distribution when I press they key in the english keyboard As I said I could achieved this behavior in the past using |
Ah I see. Actually I have to look into useHotkeys("Slash", () => setCount(count + 1)); This way, no matter the keyboard layout, it will always listen to the key which is the slash key in US layout. |
I forgot about slash, I tried before. The good news is that worked for me, so thank you so much @JohannesKlauss. Can I suggest to add this to documentation as a use case, because I didn't see it there and would be very helpful for other devs. Also I would want to suggest if it's possible to include the types for all the key strokes in the call of the hook, as useHotkeys(keys: KeysType[], callback, options). You have a link to another library that did that in the documentation, perhaps include it inside the library will improve the use of it and reduce the errors. |
Well version 5.0.0 is not officially out yet, I am currently overhauling the docs, but yes, this will be documented. I am unsure about the typings, because the |
I found this bug that was giving me a hard time in my repo until I dig in into your code and found what was the issue.
Everytime I hit '-' it behaves as '/', I detected it as I have one hotkey for each of this keys, I tried a lot of different things in my repo and didn't get it fix.
react-hotkeys-hook/src/parseHotkeys.ts
Line 10 in 33c02ff
You need to change
-
in favor of/
that is the actualslash
and not ahyphen
Also in the same file:
'#': 'backslash', // this should be '': 'backslash',
'+': 'bracketright', // this should be ']': 'bracketright',
The text was updated successfully, but these errors were encountered: