How do I remap the Caps Lock and Ctrl keys?
I'd like to remap my keys such that Ctrl behaves as the Caps Lock key and vice-versa. Also, if possible I'd like the settings to be available only within the currently logged-in user. How can I achieve this?
I'm a vim user, unlike the other people who use this machine, so I'd like those settings only for my account.
13.10+:
Install and use gnome-tweak-tool
> Keyboard & Mouse
> Keyboard
> Additional Layout Options
> Caps Lock behavior
.
Pre 13.10:
Open the Keyboard Preferences dialog (System -> Preferences -> Keyboard
). On the layout tab, click the Options...
button. Expand the Ctrl key position
section and select Swap Ctrl and Caps Lock
.
Those settings should be applied each time you log in, and will only affect your user account.
Here's a way to do it without installing extra software:
setxkbmap -layout us -option ctrl:swapcaps
Source:
- http://www.noah.org/wiki/CapsLock_Remap_Howto
One of the best ways to do that graphically if you are using the GNOME shell is to install Gnome Tweak Tool:
sudo apt-get install gnome-tweak-tool
For version 3.30.0 and later:
- Open tweak-tool and click on the Keyboard & Mouse section in the left menu bar.
- Click on the Additional Layout Options button on the left.
- Under Caps Lock behavior select Caps Lock is also a Ctrl.
For older versions:
- Open tweak-tool and click on the typing section in the left column.
- You should now see the line Caps Lock key behavior on the left.
- Choose Make Caps Lock an additional Ctrl key instead of Disabled in the drop-down list and you should be good.
Enjoy your new Ctrl key!
Open the following for editing:
sudo vi /etc/default/keyboard
And edit XKBOPTIONS="ctrl:swapcaps"
Then, reconfigure:
sudo dpkg-reconfigure keyboard-configuration
or
/usr/bin/setxkbmap -option "ctrl:swapcaps"