How do I remap the caps lock key?

In the the past I used to use xmodmap to prevent the Caps Lock button from working, and then tell Launchy to handle the key press instead. I can't seem to do this anymore.

What is the best way to disable Caps Lock's normal behavior, and make it do something else?


From howtogeek.com which has a good answer for any OS.

For Linux (including Ubuntu):

setxkbmap -option <OPTION>

Where <OPTION> can be for example of:

  • caps:none – Disables Caps Lock.
  • caps:super – Caps Lock becomes an additional Super (aka Win key).
  • caps:ctrl_modifier – Caps Lock becomes an additional Ctrl.
  • caps:numlock – Caps Lock becomes an additional Num Lock.
  • caps:escape – Caps Lock becomes an additional Escape.
  • caps:backspace – Caps Lock becomes an additional Backspace.
  • caps:swapescape – Caps Lock becomes Escape, and Escape becomes Caps Lock

Note: Xmodmap is deprecated in favor of setxkbmap.


In Ubuntu 11.10 - 13.04

  1. Open the Keyboard Layout application and click the "Options" button.
  2. A list of rebinding options will apear. Select "Caps Lock key behavior".
  3. Select your preferred Caps Lock repurposing option.

Screenshot of available options


You can disable it by going to keyboard->Layouts->options->caps lock behavior and choose "disable caps lock" .


Edit:

I don't know why it seems inconvenient with another Keyboard keys.

But Launchy works fine with me after trying it with CTRL+Super+Space.

enter image description here

And you need to white-list launchy to the tray icons. See How do I access and enable more icons to be in the system tray?. Also you need to add it to the Start Up applications, as it won't work when it is not opened.


After all, As an alternative for Launcy, try Synapse for its best integration with gnome and unity.


This is basically a modification of the answer provided at https://askubuntu.com/a/223674/22073.

You can also modify the behavior of Caps Lock using an XKBOption. These changes are even propogated to the virtual consoles (/dev/tty[1-6], or Ctrl-Alt-F[1-6]).

For instance, to disable Caps Lock, you would have the following in /etc/default/keyboard:

# Check /usr/share/doc/keyboard-configuration/README.Debian for
# documentation on what to do after having modified this file.

# The following variables describe your keyboard and can have the same
# values as the XkbModel, XkbLayout, XkbVariant and XkbOptions options
# in /etc/X11/xorg.conf.

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="caps:none"

# If you don't want to use the XKB layout on the console, you can
# specify an alternative keymap.  Make sure it will be accessible
# before /usr is mounted.
# KMAP=/etc/console-setup/defkeymap.kmap.gz

Then you would run:

sudo dpkg-reconfigure keyboard-configuration

For a full list of the customizations of XKBOPTIONS, take a look at /usr/share/X11/xkb/rules/base.lst. Here's the full list from my Ubuntu 13.10 machine: http://sprunge.us/cUZO

Even more information can be found on the ArchLinux wiki: https://wiki.archlinux.org/index.php/Keyboard_Configuration_in_Xorg