Caps Lock to Control on Ubuntu

| 6 Comments | 1 TrackBack | Bookmark and Share

If you've ever used a Sun workstation, you know the joys of having a control key where most keyboards position the caps lock key. If you're an experienced user of the Interweb, you know that there is nary an occasion that calls for the caps lock. The fact that you have to hold down the shift key is a good moment to reconsider any yelling. Though I don't use the console often, it is endlessly annoying to find that I don't have a properly positioned control key when I do. I went searching for the right way to change the keyboard's layout, since I hadn't ever bothered to do it previously. I found this how-to by Gary Vollink which describes how to replace the worthless caps lock with the useful control key in all operating systems anyone ever uses.

For Ubuntu's console, it's a simple change in /etc/console-setup/boottime.kmap.gz, which can be edited directly with vi; no need to un-gzip it first. Keycode 29 is the left control key and #58 is the caps lock. If you want another control, just copy the contents of 29 to 58 and if, for some reason (lots of SQL?) you care to swap the two rather than be rid of caps lock entirely, simply swap the values after the equals signs.

In X, I had previously used Gnome's keyboard preferences to change the caps lock setting, but the above-mentioned howto showed that it could be done by adding the following option to the 'InputDevice' section of one's xorg.conf:


Option      "XkbOptions"    "lv3:ralt_switch, ctrl:nocaps"

1 TrackBack

from Caps Lock to Control in Ubuntu Intrepid Ibex (8.10) » Dinomite.net on February 5, 2009 9:53 AM

TITLE: URL: http://dinomite.net/2009/caps-lock-to-control-in-ubuntu-intrepid-ibex-810/ IP: 129.21.60.134 BLOG NAME: Caps Lock to Control in Ubuntu Intrepid Ibex (8.10) » Dinomite.net DATE: 02/05/2009 09:53:15 AM Read More

6 Comments

I personally like to map the escape key to my caps lock key so I don't have to reach for it when editing in vim. I don't know how your key bindings are setup, but I tend to use the control key much less than escape or alt.

You can also remap the keys with xmodmap on a per-user basis by adding the following to ~/.Xmodmap:

! Switch caps lock and (left) control remove Lock = CapsLock remove Control = ControlL keysym ControlL = CapsLock keysym CapsLock = ControlL add Lock = CapsLock add Control = ControlL

and executing 'xmodmap ~/.Xmodmap'

-- Mark

Thanks, Mark!

One small comment: I had to substitute "CapsLock" with "CapsLock" and "ControlL" with "ControlL".

Other than that the way you've described in your comment works great for me!

I worry that the information is out-of-date now. I don't use that method for my Linux install anymore - Ubuntu seems to overwrite things in it's own way since v7.

This month -- I've gotten nine visitors from this blog entry - interesting that it still generates traffic.

Thank you very much for the tip! I needed some way to achieve this in a non-X11 environment. It is especially useful for the the "screen" terminal manager ;). Plus, the Caps Lock was such a major pain...

This trick also works on debian squeeze. If console-setup isn't installed, which it won't be be default, the keymap is located at /etc/console/boottime.kmap.gz and is loaded by /etc/init.d/keymap.sh as one of the first actions at boot time.

Interestingly, doing this didn't interfere with .Xmodmap swapping the keys. It continued to work correctly. But now the capslock light on the keyboard is correct in X, whereas before the light would toggle when hitting the 'esc' key (the old capslock) even though it didn't have any effect. And hitting "capslock" (the old esc) wouldn't toggle the light, but would change the caps state.

Now the light is correct in X or console.

I just switched the number '1' with the number '58', after examining the format of the file. Running "/etc/init.d/keymap.sh start" made changes take effect immediately.

Just don't ever, ever swap keys on a keyboard that is not yours and yours alone. Granted that the Caps Lock key is a worthless piece of junk, but the fact is that the rest of the typing world has a mental map expecting the Control key to be at the lower-left corner of the keyboard. Expecting others to change is reminiscent of walking into a timeshare terminal room and seeing Dvorak keyboards throughout.

About this Entry

This page contains a single entry by Drew Stephens published on June 17, 2007 6:51 PM.

Malted Milk Ice Cream was the previous entry in this blog.

Fast Downloads with Metalink is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 5.1