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.
Solution 5
I use the following AutoHotkey script for this, adapted from one I found on the Vim Tips Wiki. The implementation is a bit hacky, but it "works for me." (And unlike the other answers on this page as of 2016-09-19, it fully solves the issue without any caveats that I am aware of.)
The original coder noted:
The script also tries to detect and avoid "false positives" where you press Control and another key and release both too quickly, i.e. before the timeout period.
Be sure to tweak the 250ms value depending on how good or bad your keyboard is, and your own reaction time. This is probably something to tweak experimentally to your own liking.
g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false
*CapsLock::
if (g_ControlRepeatDetected)
{
return
}
send,{Ctrl down}
g_LastCtrlKeyDownTime := A_TickCount
g_AbortSendEsc := false
g_ControlRepeatDetected := true
return
*CapsLock Up::
send,{Ctrl up}
g_ControlRepeatDetected := false
if (g_AbortSendEsc)
{
return
}
current_time := A_TickCount
time_elapsed := current_time - g_LastCtrlKeyDownTime
if (time_elapsed <= 250)
{
SendInput {Esc}
}
return
~*^a::
~*^b::
~*^c::
~*^d::
~*^e::
~*^f::
~*^g::
~*^h::
~*^i::
~*^j::
~*^k::
~*^l::
~*^m::
~*^n::
~*^o::
~*^p::
~*^q::
~*^r::
~*^s::
~*^t::
~*^u::
~*^v::
~*^w::
~*^x::
~*^y::
~*^z::
~*^1::
~*^2::
~*^3::
~*^4::
~*^5::
~*^6::
~*^7::
~*^8::
~*^9::
~*^0::
~*^Space::
~*^Backspace::
~*^Delete::
~*^Insert::
~*^Home::
~*^End::
~*^PgUp::
~*^PgDn::
~*^Tab::
~*^Return::
~*^,::
~*^.::
~*^/::
~*^;::
~*^'::
~*^[::
~*^]::
~*^\::
~*^-::
~*^=::
~*^`::
~*^F1::
~*^F2::
~*^F3::
~*^F4::
~*^F5::
~*^F6::
~*^F7::
~*^F8::
~*^F9::
~*^F10::
~*^F11::
~*^F12::
g_AbortSendEsc := true
return
Related videos on Youtube
Zameer Manji
Updated on September 18, 2022Comments
-
Zameer Manji over 1 year
I want to be able to map the Caps Lock Key to Escape if it is not pressed with any other key and Control if it is. How can I do that on Windows 7?
-
Ƭᴇcʜιᴇ007 over 12 yearspossible duplicate of How can I disable and reassign the Caps Lock key?
-
wizzard0 over 12 yearsWell, conditional reassigning is not covered there
-
staticor about 9 yearsI made it by modifying register: commons.lbl.gov/display/[email protected]/… you need restart you computer after doing this. Win7.
-
Susam Pal over 3 yearsSee github.com/susam/uncap#readme for a Windows tool that maps Caps Lock to Escape. It is extremely lightweight. No setup, configuration, or reboot is required. Just download and double-click. I developed this tool when I was looking for something lightweight that can work without system reboot or configuration files but found nothing.
-
-
Zameer Manji over 12 yearsI already have my Caps Lock key mapped to Escape with SharpKeys.
-
Lorenzo Von Matterhorn about 11 yearsplease avoid using links as answers. instead, try explaining to your best the contents of the links and only then use them as reference. if the link ever gets broken, so does your whole answer.
-
Kazark about 8 yearsIf you just want to map it to escape, you can simplify this to:
$CapsLock::Escape
and then immediatelyreturn
. -
Rishi almost 8 yearsI'm trying to understand -- so the flaw with the script is that when Caps Lock is pressed and released, both a Ctrl and Escape are sent?
-
Brandon over 7 yearsI've been using this script and it works for me. I'm using this for rebinding Caps Lock to Control/Escape for vim.
-
DavidPostill over 7 yearsPlease quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change. Currently 404 so this answer is useless.
-
Stryker over 7 yearsExcellent points. I will update the answer
-
Michael Fox over 6 yearsWorks! Just to clarify, it's an AutoHotKey script. Start here: autohotkey.com
-
Rich over 6 yearsFor the benefit of readers that may not have clicked through and seen the comments on my gist, it seems this solution only works if you press
Caps Lock
before pressingShift
.Caps+Shift+X
works butShift+Caps+X
doesn't. -
Appleshell almost 5 yearsThis will also map the ScrollLock key to CapsLock. If that's not what you want, use the value
hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00
. Useful editor for this map is ScancodeMapping from PlexData. -
ba_ul over 4 yearsWatch out: the AutoHotKey code given here led to all kinds of problems for me. The script given by dragon788, on the other hand, seems to be working well so far.
-
Cloud over 2 yearsThanks @Appleshell. Was looking into this and realised it was also doing that additional remapping. Useful introduction for newbies. And if you want to swap escape with caps lock, use this:
hex:00,00,00,00,00,00,00,00,03,00,00,00,01,00,3a,00,3a,00,01,00,00,00,00,00
-
Cloud over 2 yearsUseful site for testing keyboard presses after signing back in