-
Notifications
You must be signed in to change notification settings - Fork 34
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
Support non-English keyboards and characters by using KeyboardEvent.key #40
Comments
Also, I haven't found any way to register the |
@Bone008 |
@Bone008 I need to dig further into it to fix this specific issue, I will try to address the following asap:
As for adding support for non-english characters in key combination this might take some more time. |
@omridevk I apologize for the super late reply, somehow I received no notification of your second response. Thank you so much for considering my feedback! I am not sure what issue you are seeing with "control + ä" or other events with meta keys being pressed. According to my tests (I found keycode.info to be a good resource), when I press "control + ä", the keydown event correctly contains Maybe the behavior is different on a Hebrew keyboard, since English characters are replaced by the Hebrew alphabet as far as I can tell. I suppose common app shortcuts like "ctrl + c" wouldn't work with a Hebrew keyboard otherwise? That seems like an acceptable tradeoff to me. Proper internationalization is hard :( For my project, only having a solution to (1.) and (2.) from your comment above would already be a huge improvement. Thanks! |
@Bone008 |
Closing this for now as most of it was fixed in: |
Thank you so much for looking into this! I updated and it works great. No matter which keyboard layout I pick, special characters get picked up exactly as expected (including the ones only reachable through a combination with shift, such as There is a small exception: Some keys still don't get through, for example the German I believe On another note, I think people will be confused about the API change that "shift + letter" no longer works, which you mentioned in #42. Especially commands like "ctrl + shift + f" (which is still written like that in the readme btw) now need to be rewritten to "ctrl + F". Not sure if this was intentional. This becomes more problematic for numbers, since registering e.g. the command I18N is hard :( Note that I am not using any of the mentioned problematic cases in my project at the moment, so personally I don't need these things to work, I just discovered them while playing around and wanted to make sure they are mentioned somewhere. Thanks for your time! |
This is not the change, perhaps the docs are not clear, all it means that if you want to use the character + you would have to write "plus" and not "+", since that never worked before. I see your point, let me check it real quick. And happy to hear that it solves a lot of the issues, can you please open issues for the remaining bugs? so I can keep track of them? |
I have checked and all keyboards short cuts like "ctrl + shift + f" still works as expected. |
Guess i'll have to adress that issue, thanks a lot for bringing that up. |
Using version 8.2.0, registering the command I thought your comment in issue 42 implied that the change was intentional. |
yes. I am fixing it now |
okay version 8.2.3 is up and running, can you please check, or better yet, create a sandbox for us to play with? |
And thank you for the help, it is much appreciated!!! |
i will update my comment in the original issue with the new solution. |
Describe the bug
Trying to register shortcuts for special characters (for example
#
) does not work with a non-US keyboard layout.Registering letters not in the English alphabet (for example the German "ä") is completely impossible.
Cause
Currently this library seems to use the deprecated
KeyboardEvent.which
property with some manual mappings for special characters.Suggested fix
I suggest switching to
KeyboardEvent.key
, which correctly handles foreign keyboard layouts and automatically assigns standardized names to non-printable characters such as arrow keys, home, end, etc.It also handles characters only reachable by pressing Shift (e.g. to obtain '?' from Shift+/ on a US keyboard) automatically: When the combination is pressed, the
key
property will contain"?"
, so no manual mapping will be necessary and it will work across all layouts.Browser support for that property is quite consistent nowadays, so compared to the current behavior it would be a big improvement. You can still use
String.fromCharCode(e.which)
if 'key' is unavailable as a fallback.The text was updated successfully, but these errors were encountered: