Skip to content
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

Keyboard Shourtcuts for Italian Keyboard #134961

Closed
Mr-Vipi opened this issue Oct 13, 2021 · 1 comment
Closed

Keyboard Shourtcuts for Italian Keyboard #134961

Mr-Vipi opened this issue Oct 13, 2021 · 1 comment
Assignees
Labels
*as-designed Described behavior is as designed keyboard-layout Keyboard layout issues linux Issues with VS Code on Linux

Comments

@Mr-Vipi
Copy link

Mr-Vipi commented Oct 13, 2021

Issue Type: Bug

I've used vs code through windows but I recently started using it through linux and one of my usually default keyboards that I'm used with Windows version of vs code is different to Linux. I know that I could change it but I like to stick to the defaults. But what is a problem is that as you can see below there are 2 different commands for the same shortcut, and I think that this is not a normal behaviour. In windows with italian keyboard, the comment toggle shortcut is ctrl+ù, in linux as you can see when I press the same combination of keys, "ù" is recognized as [Backslash]

Edit: I did the screen with all the extensions disabled

Peek 2021-10-13 08-51

VS Code version: Code 1.61.0 (ee8c7de, 2021-10-07T18:11:02.929Z)
OS version: Linux x64 5.13.0-7614-generic
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (8 x 1463)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 7.66GB (0.24GB free)
Process Argv --unity-launch --crash-reporter-id f2f6962a-82be-420e-a35b-7487b51fd026
Screen Reader no
VM 0%
DESKTOP_SESSION pop
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP pop
XDG_SESSION_TYPE x11
Extensions (42)
Extension Author (truncated) Version
better-comments aar 2.1.0
vscode-javascript-repl ach 0.7.2
Bookmarks ale 13.2.2
emojisense bie 0.9.0
turbo-console-log Cha 2.1.7
npm-intellisense chr 1.4.0
path-intellisense chr 2.4.0
gitignore cod 0.7.0
vscode-eslint dba 2.2.1
vscode-faker dee 1.5.0
githistory don 0.6.18
es7-react-js-snippets dsz 3.1.1
gitlens eam 11.6.1
vscode-html-css ecm 1.10.2
vscode-npm-script eg2 0.3.22
LogFileHighlighter emi 2.13.0
prettier-vscode esb 9.0.0
auto-rename-tag for 0.1.9
remotehub Git 0.15.0
live-sass gle 5.1.1
icon-fonts idl 2.5.2
svg joc 1.4.12
vscode-peacock joh 3.10.1
vscode-colorize kam 0.11.1
vscode-gutter-preview kis 0.27.1
template-string-converter meg 0.5.3
vscode-language-babel mgm 0.0.35
dotenv mik 1.0.1
vscode-language-pack-it MS- 1.61.5
live-server ms- 0.2.9
indent-rainbow ode 8.2.1
heroku-command pko 0.0.8
vscode-css-peek pra 4.2.0
vscode-fileutils sle 3.4.5
code-spell-checker str 2.0.10
code-spell-checker-italian str 0.1.9
savecode thi 0.1.4
vscodeintellicode Vis 1.2.14
vscode-icons vsc 11.6.0
JavaScriptSnippets xab 1.8.0
vscode-surround yat 1.2.2
html-css-class-completion Zig 1.20.0

(1 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
pythonvspyt602:30300191
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt639:30300192
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
pythonvsuse255:30340121
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
vsccppwt:30378364
pythonvssor306:30344512
bridge0708:30335490
pygetstartedt2:30371810
dockerwalkthru:30377721
bridge0723:30353136
pythonrunftest32:30373476
pythonf5test824:30373475
javagetstartedc:30364665
pythonvspyt187:30373474
vsqsis300:30374797
vsaa593cf:30376535
vssld246cf:30379912

@alexdima
Copy link
Member

alexdima commented Oct 13, 2021

This is working as expected. Windows and Linux are very different in the way they handle keyboard input and VS Code does the best it can. I will link to an issue that tracks improving things lower.


On Windows, there are two conceptional mappings, the first one is the mapping from scan code to key code, and the second one is the mapping from key code and modifiers to produced characters:

  • A good example for the first mapping is in the German keyboard layout where Y and Z are flipped. This flipping occurs in the first mapping, so the scan code for [KeyY] now produces the key code of Z and the scan code for [KeyZ] now produces the key code of Y.
  • A good example for the second mapping is in the Italian keyboard layout where the scan code for [Digit7] still maps to the key code of 7, but Shift+7 now produces / under the Italian keyboard layout instead of & as it does on the US English keyboard layout.
  • Windows has tried to simplify things with this double map approach, and all applications are supposed to dispatch on Windows on KeyCode (named virtual keys in official documentation), and VS Code dispatches on key codes by default on Windows.
  • In VSCode sources, Toggle Line Comment command is bound by default to Ctrl+/, but that means it is mapped to Ctrl + VK_OEM_2 (you can find a table of virtual keys here). VS Code does not ship with keyboard layout specific keybindings, so the default keyboard shortcuts are not optimized for all keyboard layouts. This is tracked in Support contributing different keybindings based on keyboard layout #1240.
  • I have installed the Italian keyboard layout on Windows, and the scan code that is bound to VK_OEM_2 in the first map is [Backslash]. (the mapping can be seen using Developer > Inspect Key Mappings):
	"Backslash": {
		"vkey": "VK_OEM_2",
		"value": "ù",
		"withShift": "§",
		"withAltGr": "",
		"withShiftAltGr": ""
	},
  • So that means that on Windows + Italian keyboard layout we will trigger Toggle Line Comment by default when pressing Ctrl+[Backslash] i.e. Ctrl+VK_OEM_2 i.e. Ctrl+ù.
  • Also of note, we have two default keybindings bound to Ctrl+VK_OEM_2:
    image
  • This is not a problem, it is possible to have two actions bound to the same keybinding as long as the when clauses don't overlap too much. The second command, toggleExplainMode is also bound to Ctrl+VK_OEM_2

On Linux, there is a single conceptual map from scan code + modifiers to produced character. There is no intermediate hop, there are no intermediate virtual keys like on Windows. So when we ship with a default keybinding of ctrl+/, it does not mean ctrl+VK_OEM_2 on Linux, because VK_OEM_2 does not exist as a concept at the OS level. We have chosen to do the following: we try our best to map ctrl+/ (the default keyboard shortcut) to the key combination that would produce / and then add the same modifiers. On the Italian keyboard layout under linux, it is shift+[Digit7] that produces /. This can also be observed using Developer > Inspect Key Mappings:

	"Digit7": {
		"value": "7",
		"withShift": "/",
		"withAltGr": "{",
		"withShiftAltGr": "⅞",
		"withLevel5": "7",
		"withLevel3Level5": "{",
	},

So, given / is produced using shift+[Digit7], we map the default keybinding ctrl+/ to ctrl+shift+[Digit7] on Linux on the Italian keyboard layout. Also in this case, there are two actions using the same keybinding, just like on Windows:
image


I'm sorry about the long explanation, but I hope that explains what is going on. The only way to improve here is #1240 , which would mean that we would ship with default keyboard shortcuts optimized for Italian, Spanish, German keyboard layouts, etc. That would allow us to make an individual decision if we want to map Toggle Line Comment to ctrl+shift+[Digit7] on Linux (as it maps automatically today) or to ctrl+[Backslash] which would be the spiritual equivalent to what Windows is doing.

On the bright side, if you don't like the way our defaults have resolved, you can very easily edit them using the UI we have and map them to your liking.

You can also read more about it here.

@alexdima alexdima added *as-designed Described behavior is as designed keyboard-layout Keyboard layout issues linux Issues with VS Code on Linux labels Oct 13, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed keyboard-layout Keyboard layout issues linux Issues with VS Code on Linux
Projects
None yet
Development

No branches or pull requests

2 participants