There are several ways to swap the Caps Lock and Control keys. However, I want both of them to function as Control. In addition, I still want to keep Caps Lock somewhere just in case, so I decide to use the left Windows key as Caps Lock. This is achieved by putting the following in .xinitrc (or something similar, e.g., .Xclient).

  xmodmap -e 'remove Lock = Caps_Lock'
  xmodmap -e 'remove Control = Control_L'
  xmodmap -e 'remove Mod4 = Super_L'
  xmodmap -e 'keycode 66 = Control_L'
  xmodmap -e 'add Control = Control_L'
  xmodmap -e 'keycode 115 = Caps_Lock'
  xmodmap -e 'add Lock = Caps_Lock'

Note that 66 and 115 correspond to the Caps Lock key and the left Windows key, respectively. You can get these using the program xev. Also, after I upgraded to Red Hat 9 (from 7.1), I had to add the 'Super_L' line to make it work. My guess is that the newer XFree started recognizing the Super_? keysym of the Windows keys.

Last modified: Sat May 1 14:33:30 EDT 2004 using Vim
by pach at cs.cmu.edu