Manicai.net

Swapping Caps Lock and Control

Swapping Caps Lock and Control on Windows

If you've got used to a Solaris or other Unix box you may well have got used to having the control key where the caps lock key is on windows keyboard. Even if you haven't then you may believe that it is a more sensible way round to have the keys. It is possible with more or less effort to fix this under Windows.

Please note that although I've used the settings given here without a problem, I make no warranty or guarantee - if you stuff up your computer I am not responsible

Windows 2000 and XP

To do this requires some registry hacking. Run regedit and burrow down to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout

Here you need to add a binary entry called Scancode Map with a value of 00000000 00000000 03000000 3A001D00 1D003A00 00000000.

If you want to try it I have an exported registry branch that you can import with regedit and that should have the same effect. Download it here. I've tried this a couple of times on computers running different service packs of Windows 2000 and it seems to work, but I take no responsibility if it does something horrible to your machine.

For more information on the Scancode Map key look at this Microsoft Article.

Windows NT 4

I don't use NT and so haven't investigated this particularly, but as far as I know neither of the other methods here work, and I am not aware of another way. Sorry. (If you do find a way then let me know and I'll update this.)

Windows 95 and 98

For Win 95 and 98 you need to get hold of the Microsoft Kernel Tools pack, which is a bit like the better know Power Tools (of which TweakUI is the most well known element). This can be found on the Microsoft web site.

Windows 3.x

(Anyone still use it?) Sorry, your on your own. (Let me know if you have a way.)

Swapping on Linux

XFree86 Version 4.x

If you are the only person using the machine then the easiest option is to include the following line in the keyboard section of your XF86Config-4 file.

      Option          "XkbOptions"    "ctrl:swapcaps"
These ensures that the swap is done automatically whenever X starts. If you're not the only person using the system and/or you don't have sufficent permissions to make this change then use the technique for XFree86 version 3 given below.

XFree86 Version 3.x

You need to use xmodmap. The man page gives the exact details but basically put the lines

            !
            ! Swap Caps_Lock and Control_L
            !
            remove Lock = Caps_Lock
            remove Control = Control_L
            keysym Control_L = Caps_Lock
            keysym Caps_Lock = Control_L
            add Lock = Caps_Lock
            add Control = Control_L
in a file (.xmodmap is good). Then add the line xmodmap ~/.xmodmap in your .bash_profile or some other file that is run when you login or start x.

Console

Thanks to Osvaldo Santana Neto (osvaldo at rantac dot com) for this information. The key layout is control by a keymap file. This can be found in a number of places depending on your linux distribution. Possibilities I know of include:

  • /usr/lib/kbd/keymaps/_arch_/_kbdtype_/_keymap_.gz
  • /usr/share/kbd/keymaps/_arch_/_kbdtype_/_keymap_.gz (used by SuSe).
  • /usr/share/keymaps/_arch_/_kbdtype_/_keymap_.gz (used by Debian).

Where _arch_, _kbdtype_ and _keymap_ are substituted appropriately. For instance on my Thinkpad running SuSe 8.2 I'd look at /usr/share/kbd/keymaps/i386/qwerty/uk.map.gz

In this file should be two lines that will reading like:

keycode  58 = Caps_Lock
keycode  97 = Control

You change these to

keycode  58 = Control
keycode  97 = Caps_Lock

ian@manicai.net

Last Update 24 Oct 2006