I'm upgrading my development setup and thought about using Windows with WSL 2 as an alternative to a crashing Ubuntu installation. One piece of software I can't live without is xcape, a tiny X11 service that maps CapsLock to Escape when pressed for a brief time and otherwise maps it to Ctrl.
I'd like to achieve the same mapping from CapsLock to Ctrl/Escape on my Windows installation, but I'm having some issues. The script at the end of this post does almost exactly what I want, except that it does not work when typing e.g. Shift+Ctrl+V in the terminal. This is probably because the script only starts working as soon as it detects the Ctrl modifier. Ctrl+Shift+V works perfectly fine, but unfortunately I tend to type the first combination a lot when I'm in a hurry.
My question is: how do I adjust the script below to take into account additional modifiers like Shift?
Code: Select all
SetCapsLockState Off
CapsLock::
key=
Input, key, B C L1 T1, {Esc}
if (ErrorLevel = "Max")
Send {Ctrl Down}%key%
KeyWait, CapsLock
Return
CapsLock up::
If key
Send {Ctrl Up}
else
if (A_TimeSincePriorHotkey < 1000)
Send, {Esc 2}
Return