-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Bizarre keyboard shortcut behaviour (UK layout) #97028
Comments
@jmaargh This topic is a bit complex. It is documented in great detail here. Can you please answer the following:
|
Thanks for the reply. I have things set up the way I want now, so don't need troubleshooting help, but I wanted to raise it as confusing and bizarre behaviour that vsode should avoid. I also appreciate that localisation (esp. where hardware is involved) is annoying and complex. Thanks for working on a great piece of software :)
no
no
yes
ISO (I think). It's the standard UK layout |
I found this as a result of hitting dbankier/vscode-quick-select#24. The issue there is that Using the "Record Keys" feature, I see that This seems like it would make it impossible to sanely define key mappings that work as expected across different keyboard layouts. |
@pfmoore I don't think it should be impossible. I'm not particularly familiar with js or electron, but good input libraries in general will report keys as scancodes which are layout-independent and OSs provide a way to map those back to what is laid out on the physical keyboard. This is how, for example, most well-made games that allow key remapping "just work" with different layouts. I suspect one problem here is that vscode is using json strings as the storage backend, which are not layout-independent because they're storing the physical key identity (e.g. I say "one problem" because the issue of one key combination adding two different shortcuts that I mentioned initially doesn't seem to be explained by this. |
@jmaargh I meant that it's impossible for users to set up layout-independent keybindings, with the current implementation. I'm sure it's possible for VSCode to be changed to fix this issue (although I don't doubt the issue isn't as simple as I'd like it to be 😉). |
To create keyboard layout independent keybindings, it is possible to use scan codes in the keybindings definitions with the
Here is a list of scan codes -- https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values |
Thanks. It seems odd to me that the "Record Keys" feature doesn't return scan codes. I can't see why I'd ever want layout-dependent results by default.... |
For portability reasons. In insiders, we already offer settings sync and keybindings will be synchronized across machines, potentially across different OSes. So we default to the most "portable" thing we have... |
Hmm, OK. Maybe I'm not understanding then. How is To be clear, using scan codes will solve my issue, so the only things I'm really discussing now are discoverability (it's hard to find out that scan codes are an option, and "Record Keys" gave no hint) and a bit of background understanding of the reasoning here. |
That's why I use quotes when saying "portable" :). Scan codes identify very well the physical key that you have pressed on your current keyboard on your current machine. But if you move to another keyboard (say from an ISO to an ANSI keyboard), it is possible that you miss a scan code (e.g. So, as broken as they are, key codes are more "portable". As for the key code So Windows has the concept of scan codes, key codes, and produced characters. So there are two maps, one from scan code to key code (which is irrespective of modifiers), and another one from key code + modifiers to produced characters. That is quite smart because it helps very many developers get correctly things like select all (Ctrl+A) or undo (Ctrl+Z) to work seamlessly under AZERTY/QWERTY, where almost all Windows APIs encourage you to use key codes. That is why early browsers exposed the concept of key codes to javascript events. Once these concepts were ported to Linux or mac (where there is a single map, from scan code + modifiers to produced characters), things started to quickly fall apart and all browsers try to guess a key code (since that concept does not exist on these platforms) In the end, browsers now also expose scan codes and that's why on Linux and Mac we dispatch by default based on scan codes. But it would be unusual to dispatch on scan codes on Windows, where all applications dispatch on key codes. This is quite a mess, so we encourage the following:
|
Thanks - nice explanation 🙂 I appreciate you taking the time to clarify all of this for me. |
Thanks for the explanation, but how did I end up with one shortcut from the recorder affecting two distinct physical key combinations (and apparently two distinct lines in the config file)? |
@jmaargh Are you OK to close the issue now? |
Steps to Reproduce:
"ctrl+shift+[Backslash]"
I assume that this is all to do with some bizarreness related to using JSON (i.e. strings) as the underlying storage medium while what "should" be stored for consistency are scancodes (which can then be interpreted and displayed whichever layout it used. While having the "incorrect" keys stored (and even appear differently in the UI) is livable with (though annoying), it's much less acceptable for one shortcut to take up two distinct physical actions. I would like to use [Ctrl] + [Shift] + [`] and [Ctrl] + [Shift] + [#] for different actions.
Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: