In this blog post, I'll tell you how to remap your Caps Lock key on Windows to Control when pressed with other keys, and Escape when pressed alone.
Why would you want this?
The Control key is used by many keyboard shortcuts in Windows, and the physical control key has awkward positioning on many keyboards.
If you use Linux and Vim on WSL2, it's import to also have the Escape key in close proximity, since it's constantly used to exit modes in Vim. Escape is also handy for software of all types, which you'll start using more, once it's in a better position
The idea to remap Caps Lock to Control, and then Escape if tapped alone was made famous by Steve Losh, in his "Space Cadet" blog post from 2012: https://stevelosh.com/blog/2012/10/a-modern-space-cadet/
That solution made its rounds among Mac web developers, particularly in the Rails community, and then later spread to Windows via various registry and AutoHotKey scripts, such as this one: https://gist.github.com/sedm0784/4443120
There was an alternate way of doing this, for people that just needed to remap Caps Lock to Control, that only involved making a registry edit via the SharpKeys program: https://www.randyrants.com/category/sharpkeys/
Combining SharpKeys and AutoHotKey v2
Some people used only SharpKeys, and some used AutoHotKey, but the best approach was to use SharpKeys to remap CapsLock -> Escape, and then use AutoHotKey to layer on the Escape functionality.
AutoHotKey v2 is currently in beta, and much improved in many ways over V1. A user posted this script for v2: https://www.autohotkey.com/boards/viewtopic.php?t=92738
- use in combination with SharpKeys for the best overall solution
I installed this version of SharpKeys:
And I installed the following key remap:
Reboot for that to take effect.
Run AutoHotKey v2 Executable on startup
Compile your AHK script into an executable:
- great! Double-click and run it... test in WSL, and everything's good!
Running an executable at startup
Drag your executable here:
- A shortcut to get there is to press WIN+R and run the shell:startup command
Note on an alternative: Dual key remap
Written in C to use the Windows API directly, this program can do both the Caps Lock --> Control and Caps Lock --> Escape remap.
I chose to use Sharpkeys/AutoHotKey because the registry hack will also work on the Windows login screen, and I always have AutoHotKey installed on Windows anyway.