Swap Caps Lock and Ctrl

From LQWiki
Jump to: navigation, search

Many people find it convenient to swap the Control and Caps Lock keys on their keyboards or remove Caps Lock entirely. To accomplish this in the X Window System you will have to edit your XFree86 configuration file. The location and name of this file varies between Linux distributions but the most common location is the file:




in more recent distributions that have replaced XFree86 with the X.org server.

Edit this file with your favorite text editor and look for a section that looks something like this:

Section "InputDevice"
    Identifier  "Keyboard0"
    Driver      "keyboard"

    Option  "XkbRules"      "xfree86"
    Option  "XkbModel"      "pc104"
    Option  "XkbLayout"     "us"
    Option  "XkbVariant"    "basic"
    Option  "XkbOptions"    "grp:menu_toggle"

To swap Control and Caps Lock, add this line

    Option  "XkbOptions"    "ctrl:swapcaps"

To make both Control and Caps Lock function as Control, add this line

    Option  "XkbOptions"    "ctrl:nocaps"

Restart X-Windows for the changes to take effect.

Recently, this process has become somewhat obsolete. In GNOME 2.6 and later, editing the XFree86 config file is no longer necessary. The behavior of the Caps Lock key can be modified from a convenient control panel in the Preferences menu.

See also