Remap Caps Lock in Windows (escape *and* control)
This script registers a single press on CapsLock as a press that lasts less than 400ms, modify that value as needed.
*CapsLock::
Send {Blind}{Ctrl Down}
cDown := A_TickCount
Return
*CapsLock up::
If ((A_TickCount-cDown)<400) ; Modify press time as needed (milliseconds)
Send {Blind}{Ctrl Up}{Esc}
Else
Send {Blind}{Ctrl Up}
Return
Related videos on Youtube
rationalis
Updated on September 18, 2022Comments
-
rationalis over 1 year
There's plenty of utilities that remap keys, but I can't seem to find a very specific feature: I want to have caps lock act as the control modifier key when held down, but as escape when pressed on its own.
A similar question was posed here, and one of the answers provided an AutoHotkey script, however it is susceptible to the timing of key presses and only handles a hard-coded list of all possible control+letter combinations. I would prefer it if it would function without quirks, blocking caps lock pressed events, storing any other keys pressed while the caps lock key has not yet been released, and then deciding whether to send escape or control.
Is there a simple utility or a more generic AutoHotkey script that does this?
-
Rich over 10 yearsFWIW, whilst I also don't like the answer I posted, I haven't ever experienced any issues with it in practice, so if the answer below isn't working for you (as you state in comments), it's worth trying out, at least.
-
rationalis over 9 yearsThe answer you posted to the other question also seems to not work with key chords. Specifically, it seems to work only with right shift. For example, I'm pressing CapsLock+Shift+Tab and trying to get Ctrl+Shift+Tab. Pressing CapsLock+LShift+Tab doesn't seem to generate anything at all, but CapsLock+RShift+Tab works fine.
-
Rich over 9 yearsNot sure what's going wrong for you, but CapsLock+LShift+Tab works for me. (e.g. it successfully switches tabs in reverse order in Chrome.) I'm currently running on Windows 8.1 but I'm pretty sure it worked in Windows 7 and Windows 8, too.
-
-
rationalis about 11 yearsFor some reason, it doesn't work properly with multiple keystrokes, e.g. Ctrl+Shift+Tab or Ctrl+Alt+Del, although it works fine for 2-key combos like Ctrl-A or Ctrl-Tab.
-
Elliot DeNolf about 11 yearsI was missing an * before the first CapsLock hotkey. The Ctrl+Shift combinations will work now. Ctrl+Alt+Del however is a special shortcut that cannot be sent from AutoHotkey.
-
rationalis about 11 yearsThe asterisk doesn't seem to have made any difference for me.
-
Mike H-R over 9 yearsworks completely fine with ctrl+shift combinations for me. Thanks.