To achieve a low-level swap of left ctrl
key and capsLock
key, I used xkbcomp
as follows:
First get the present keyboard layout:
xkbcomp $DISPLAY output.xkb
Then I change the 2 lines in output.xkb
from
<LCTL> = 62;
...
<CAPS> = 66;
to
<CAPS> = 62;
...
<LCTL> = 66;
Then run
xkbcomp output.xkb $DISPLAY
to take it into effect. It works perfectly in most desktop applications. But the problem is with vscode
. Actually it also works well in the normal mode of vscode
, but when I try to change a shortcut in vscode
and it prompt me to press new keys to change the shortcut, I pressed the capsLock
key on my keyboard and vscode
thinks that I pressed ctrl
+capsLock
simultaneously. This is not what I expected, vscode
should not know my capsLock
key, it should only know I pressed ctrl
key because XServer
should only tell vscode
that I pressed ctrl
key. I think it is because my configuration is not complete so that vscode
could still detect my capsLock
key. Can anyone tell me how to do a complete swap of ctrl
and capsLock
? xmodmap
should not be the solution because it is based on xkbcomp
and with limited function.
Unfortunately, I have the same behavior as you in VSCode, but I am using the following workaround until further notice:
Edit the file output_mod.xkb according to my ideas.
If I work in vscode normaly, I use
If I edit keyboard shortcuts, I use before:
Make my changes with original-keys and then set the layout back to key swap:
Ok, that's not very clever but effective for this particular problem.
/// EDIT ///
After some research, it seems like there is a better solution especially for the vscode behavior:
In Terminal:
Insert code:
If code already exists in this file:
Restart vscode.