Remap Caps Lock as Backspace in Windows and Linux

A while back my wrist started hurting from reaching for the cursed backspace key. I was making too many mistakes. My solution was to remap the caps lock key on all the computers I use to act as an additional backspace key. How did I do it? Well, I'm glad you asked. I'll tell you.

In Windows
EDIT: I noticed that the picture doesn't have all the detail you need. The easier way to do this, is to download the registry key attached to this post, and to right click it, selecting merge. After that, restart the computer, and you should be all set.

To remap the caps lock to function as a backspace key in Windows, one must edit the registry keys. To do that, go to Start > Run..., and type in regedit. In the editor that opens up, navigate to the key shown in the picture below, and create a new key named Scancode Map of the type REG_BINARY. Give it the value shown in the picture, restart, and you're set. If things get wacky, delete the key and try again.

In Linux
I have tested the following in Ubuntu 7.04, 7.10, 8.04, 8.10, and 9.04. Start by opening a terminal, and running the xev program. Once that is running, press the caps lock key, and it will tell you the numerical value of that key. For example, my output from that command looks like this:

mlissner@opal2% xev
KeyPress event, serial 28, synthetic NO, window 0x4800001,
    root 0x59, subw 0x0, time 2775892, (373,636), root:(376,685),
    state 0x0, <strong>keycode 66</strong> (keysym 0xff08, Caps_Lock), same_screen YES,
    XKeysymToKeycode returns keycode: 22
    XLookupString gives 1 bytes: (08) "
    XmbLookupString gives 1 bytes: (08) "
    XFilterEvent returns: False

In there, you will see the keycode for the capslock key, in my case, number 66. Using that, create a file in your home directory called .Xmodmap, and put the following in it:

!
! Make the caps lock button a backspace button
!
remove Lock = Caps_Lock
keycode 66 = BackSpace

Once that is done, the next time you log in, your caps lock will function as a backspace. The only remaining problem is that it still does not have the auto-repeat function that backspace should have. To fix that, run:

xset r 66

That will make things work properly, but you need to run that every time you log in, or else it won't work properly. To fix that run:
sudo gedit /etc/X11/Xsession.d/50x11-common_determine-startup

And add xset r 66 to the bottom.

That should do it.

Source: http://ubuntuforums.org/showthread.php?t=369402

AttachmentSize
Scancode Map.reg1.07 KB

Hi!

Very good description. thank you. it is also nice that you provided the solution for both operation system, linux and windows.

Glad you like it! I should probably fix that Windows part one of these days, but it gets the job done.

I also just discovered these:

  • Control_L & Control_R
  • Super_L & Super_R
  • Shift_L & Shift_R

Excellent! With your help I could easily remap CapsLock key to Escape on Ubuntu, meaning much more comfortable shortcuts when I am in my favorite editor, and much less spurious cAPSlOCK errors when I'm not. Many thanks!

My pleasure. That was an idea I had too for caps lock, but in the end, I had to go with backspace.

Nice tutorial, although I had to change it a bit to work. When I tried it in Ubuntu 8.10, the caps lock key also retained its old effect (may be because I previously messed up keybindings when replacing it with a Ctrl, but later decided that Backspace would be a cooler idea ;) ), which I was able to fix with replacing the line
remove Lock = Caps_Lock
with
clear Lock

In Windows (yes, I tried it in both OSes), it seems the register hack supplied also changed the keyboard layout to English. After restoring everything except the "Scancode Map" line using a backup and rebooting, I got it working.

Works like a charm now though. Thanks!

That's interesting to know. Thanks for the update. I'm surprised the reg key changed the keyboard to English, but MS never ceases to surprise me. Sorry about that.

It sounds like the earlier problem was from the Ctrl changes you had made, but who knows. Glad it's working out.

Thank you!
I was looking for a way to make the backspace(caps) auto-repeat even after suspend. Otherwise, a startup entry would have done the job. This does it.

I made a portable app to remap Caps Lock to Backspace without rebooting on Windows 7/Vista/XP/2000/NT. It uses a global keyboard hook to intercept Caps Lock keypresses and simulate Backspace keypresses instead in less than 100 lines of C++ code. The source code is free to use and the executable is only 3.50KB in size.

Just in case anyone else ends up here, in ubuntu (at least 10.10), look under system/preferences/keyboard/layouts/options/capslockkeybehaviour to modify the capslock to do all sorts of things, including function as an additional backspace.

Alas, this no longer works on Windows 7.

Your windows picture does not show the full key.