-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Keymap based on .key or .code rather than .keyCode? #74
Comments
Note on my mac that I was testing, Shift-Alt-2 prints |
Use case: Someone wants the default shortcut key for an action to be Shift + |
Use case: As a user of an application, I don't like the default shortcut for an action. I decide to remap it to Alt + 0 while using an en-US keyboard (doesn't resolve to a printable character). Later on I connect my Bluetooth keyboard that has another layout. This layout has a printable character that is only accessible by pressing Alt Gr + 0 (e.g. on a nb-NO keyboard it produces
|
(updated by comments above to have the use cases listed alone without including my opinions) |
I should say that one very nice thing about our current system is that, given a keyboard mapping, it is unambiguous about what keys to press. The codes are tied to physical keys, and the name of that key is the primary character of that key, i.e., the thing silkscreened on the key as the primary character. For example, on my US-en keyboard, even if I change the OS keyboard mapping, a given key still produces the same Just curious, for your second usecase, aren't Alt and Alt Gr two different keys? |
Also, since keyboard mappings are an explicit part of the Lumino shortcut system, it is easy for us to detect the user changing it and swap out completely different shortcuts for different layouts. |
For the record, I'm happy to close this issue and decide that using |
Also for the record: I'm neither for nor against this change, I just saw it proposed without outlining what problem it would solve and tried to ask about it (in jupyterlab/jupyterlab#7579) and this was supposed to be the details for that, but I was still left confused. As far as I can tell at this point, the main points of interest of the keymap design is (likely to have some mistakes, so please correct as needed):
|
From reading the W3C spec, it looks as if using |
The details I was referring to there was the evidence (in the OP above) that browsers are inconsistent with how they handle |
What a nice world it would be if everyone followed the spec 😄 |
+1 to exploring this idea, basing the keyboard shortcut system on |
For summary/context, here are some concerns that would be relevant when having a shortcut system in an app:
Anything else? Can we expand on this and use it to form a recommendation for how to modify the system currently in lumino, and write a recommendation for how to build shortcut systems on top of that (i.e. documentation). My initial pass on that would be: Changes to lumino:
Recommendations for applications:
I think the current system is pretty close to this, so a change of the fundamental logic will hopefully not be needed. |
I think so! |
I'm having a look at implementing the lumino side of this. |
I have a draft PR up (#291) with the code I think we will need, but I have some questions about how to best organize it into packages. For now I have:
Open questions I have:
|
Other points of discussion that I mentioned previously that are not covered by that PR:
This conflicts partially with our wish "There actually exists a key on the keyboard with that key legend". E.g. the current en_US layout has numpad keys, but some keyboards might not include that. I think this probably sets the precedent for the layout to include keys that might not actually be present on the keyboard, i.e. changing the wish to "If the key actually exists on the keyboard, it has the correct key legend". We might want to take the approach "All special key values are valid unmodified keys". I.e. if a user clicks a "MediaPlay" key without any modifiers then both |
Early in Phosphor/Lumino's development, we decided to use
.keyCode
instead of.key
for the basis of the keyboard shortcut system. This came about in part because (among other things) we realized that browsers were inconsistent with the.key
attribute when modifiers were used. For example (and I just checked this is still the case with Firefox 76), in Firefox we saw that on a mac, pressing the numbers on a en-us keyboard layout while holding shift, control, alt, and command, led to the following sequence of event.key
attributes:On Chrome, we get:
I suppose once browsers can be consistent about
.key
, we can look again at a keyboard shortcut system that depends on it. A nice thing about using.key
is that presumably it would transparently support different keyboard maps, instead of relying on manually creating and selecting keyboard maps.Another option, as @vidartf points out below, is moving to the
.code
attribute, especially since.keyCode
is both deprecated and a bit convoluted across different browsers.The text was updated successfully, but these errors were encountered: