- use
xev
to find out which key you want to remap; - create a file in your home directory called
.Xmodmap
; - here’s an example of to remap a key:
- add the following line to your
.bashrc
to make it permanent:
- finally, to apply the changes to your current session, reload your
.bashrc
file by running the following command:
Remap <Caps_Lock>
to <Escape>
The method described above cannot be used to remap the <Caps_Lock
> key. I am unsure why, but it retains its original behavior despite the new one assigned by xmodmap. Fortunately, it is still possible to remap it as intended by other means.
When using GNOME
If you’re using GNOME, you can remap the <Caps_Lock>
key by following these steps:
- install
gnome-tweaks
; - go to Keyboard and Mouse;
- go to Additional Layout Options;
- click on Caps Lock behavior;
- click on Make Caps Lock an additional Esc.
Note that this method may not work in Hyper-V, but it should work in VMware.
When using i3
If you’re using i3, add this to the end of your i3 configuration file ~/.config/i3/config
:
To take effect, you have to restart i3. You can do this by logging out and logging back.