Mapping Caps Lock to Escape and Control on Windows 7

Solution 1:

You can remap it to Escape with SharpKeys

However, I don't know of a realistic way to perform conditional remapping, other than writing a keyboard driver.

Solution 2:

This may have appeared on the previously mentioned vim wikia page after Rich's solution above.

; Author: fwompner gmail com
#InstallKeybdHook
SetCapsLockState, alwaysoff
Capslock::
Send {LControl Down}
KeyWait, CapsLock
Send {LControl Up}
if ( A_PriorKey = "CapsLock" )
{
    Send {Esc}
}
return

This is not my work, but I've started using it and it works exactly as described, no real caveats, and because it doesn't attempt to map any exceptions (because they are unnecessary) it behaves quite nicely in Chrome (I really wanted it for Vimium).

Solution 3:

This is not exactly what you want but very close if you can live with some flaws. Here's an AutoHotKey script:

$CapsLock::LControl
$CapsLock Up::Send {Escape}
return

It remaps Caps Lock to Ctrl and sends Escape when you release the key. It took me a while to get used to the Escape key being pressed every time I let go the Caps Lock key. However it's pretty much useless on website textareas because pressing Escape loses the focus on the textarea.

I'm looking for a solution to this though. I might go as far as write some sort of driver/keyboard hook in C if needed, haha.

Vim-specific annoyances: It makes digraphs impossible to type using the Ctrl-K combination and is generally plain annoying before you get used to it. It works well for me though because I'd do anything to avoid Esc and Ctrl keys as much as possible.

Solution 4:

Here is a registry entry that maps the caps lock to escape on windows 7.


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,46,00,01,00,3a,00,00,00,00,00

Save the above to a file with a .reg extension (like mapCapLocks.reg) and import/execute it on your machine. This can be done by clicking that file in the File Explorer, and then signing out and signing in again.