Last active
September 27, 2023 03:12
-
-
Save brombres/e1d9a53ff915653a87b91efb7a3db33f to your computer and use it in GitHub Desktop.
AutoHotkey 2.0 Caps Lock to Escape and Control (Windows)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v2.0 | |
#SingleInstance | |
; Caps Lock is ESC if tapped (pressed and quickly released). | |
; Caps Lock is CTRL if held down. | |
; Install AHK 2: https://www.autohotkey.com | |
; Create CapsLock-to-ESC-and-CTRL.ahk in Startup containing this code. | |
; (File Explorer/Dialog > type in: Startup) | |
; Double-click to run | |
; Will auto-run next startup | |
global cDown := 0 | |
; Hold down RIGHT CTRL and tap CAPS LOCK to toggle CapsLock | |
>^CapsLock::CapsLock | |
; CapsLock is pressed - send CTRL Down | |
CapsLock:: | |
{ | |
Send "{Blind}{Ctrl Down}" | |
global cDown := A_TickCount | |
} | |
; CapsLock is released - send CTRL Up. | |
; Also send ESCAPE if the press & release was quick enough. | |
CapsLock up:: | |
{ | |
; Modify the threshold time (in milliseconds) as necessary | |
if ((A_TickCount-cDown) < 150) | |
{ | |
Send "{Blind}{Ctrl Up}{Esc}" | |
} | |
else | |
{ | |
Send "{Blind}{Ctrl Up}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment