-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Replace event.which with event.key in shortcut handlers #724
Conversation
Fixes issues with foreign keyboard layouts
… to check if it exists
Hey - thanks a lot for this PR. Unfortunately browser support for Not sure if we should just roll with this / ignore browser support, or switch to an implementation that checks both |
I thought about checking both to support older browsers, but I was not aware of the flawed Edge support. As you said, there seems to be a fix on its way, but the tablet issue would still be a problem. I think we really have to check both – event.key and event.which, but I am not sure if we should work around the flawed implementation of Edge and IE11 or just wait for the fix in Edge and ditch IE11 support altogether. |
A cursory search turned up cvan/keyboardevent-key-polyfill, which appears to polyfill |
Sorry for the delay on this. I was ready to merge and ignore the Android / Edge compatibility issues (given their low impact), but after testing I found that the |
Oh, I see … The best way to somehow get the original key value without modification. But I don’t know if that is possible at all. |
(extremely late response, I'm aware) I don't really know what to do with this. As far as I can see it's basically like this:
The current implementation seems to work correctly on English keyboards on all browsers (even though there are still issues like #946), so I'd vote to close this PR until we come up with a better solution. I think it's highly unlikely that @j-f1 what do you think? |
Oh yeah this is an old one and not much has changed since my last post. Even if we could, detecting keypresses like It gets even more confusing when you try to assign a key combination like Cmd + ?. In order to get that you would need to press Cmd + Shift + ß. The Keyboard event that is triggered has a Long story short, I think the current keyboard events are really bad to do shortcuts that depend on specific characters instead of specific key locations. Until we have a better choice, I think closing the issue is the right thing to do. :/ |
It's indeed confusing. Maybe in the future we can implement custom keyboard shortcuts with a library like Mousetrap which has the ability to record keyboard sequences, but that's quite a big change and out of scope for this PR. I'll close this PR for now. Feel free to open a new one if you (or anyone else) has a better solution for this issue. |
Since
event.which
has some issues with non-english keyboard layouts and is deprected, I replaced all instances ofevent.which
withevent.key
.Fixes #723 and some other broken shortcuts. For example I could not use the
?
shortcut to get to the help menu, which is possible now.I have tested it with a german and an english keyboard layout.