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.

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

Microsoft Windows

Windows 2000 and later.

Mark Russinovich, previously of SysInternals and now at Microsoft has written a keyboard driver, Ctrl2Cap, that hard codes this that avaiable from Technet, which should work on anything more recent that Windows 2000.

Another alternative is to use one of the various keyboard remapper utilities around. I have used Key Remapper from Softarium with some success although it does very occasionally not translate the key press. This seems the best solution if you have to share a computer with someone who doesn’t have the same prejudices.

Screenshot of Softarium's KeyRemapper configuration screen

Windows 2000 and XP via the Registry

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

Mac OS X

At least on recent versions of OS X this is very easy and can be done via the “Keyboard & Mouse” pane of “System Preferences” via the “Modifier Keys…” button.

Modifier Keys dialog of the Mac OS X System Preferences

Linux

[I no longer have a Linux install handy to try the following on.]

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

Peter Desnoyes e-mailed to say that alternatively you can just set the keymap to “emacs” to get the same effect.