June 17, 2007

Caps Lock to Control on Ubuntu

Drew Stephens @ 8:51 pm — Tags: , ,

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"

Related Posts:

3 Comments »

  1. 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

    [Reply]

    Comment by Mark Tran — June 19, 2007 @ 2:22 pm

  2. 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!

    [Reply]

    Comment by Eric — November 18, 2007 @ 12:01 pm

  3. 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.

    [Reply]

    Comment by Gary Allen Vollink — July 25, 2008 @ 3:08 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress