Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Benjaminlooi/df5326c7c37e54aa285173243fb9152e to your computer and use it in GitHub Desktop.

Select an option

Save Benjaminlooi/df5326c7c37e54aa285173243fb9152e to your computer and use it in GitHub Desktop.
AutoHotkey v2 script to Remap Caps Lock to a Hyper key (Ctrl+Alt+Shift+Win) on hold, Escape on tap, and preserves actual Caps Lock via Shift+Caps.
#Requires AutoHotkey v2.0
; *CapsLock::
; {
; startTime := A_TickCount
; Send("{Ctrl down}{Shift down}{Alt down}{LWin down}")
; KeyWait("CapsLock")
; Send("{Ctrl up}{Shift up}{Alt up}{LWin up}")
; if (A_TickCount - startTime < 200) && (A_PriorKey = "CapsLock")
; {
; SetCapsLockState(!GetKeyState("CapsLock", "T"))
; }
; }
; 1. Shift + Caps Lock = Toggle actual Caps Lock
+CapsLock:: {
SetCapsLockState !GetKeyState("CapsLock", "T")
}
; 2. Caps Lock = Hyper (Hold) or Escape (Tap)
*CapsLock:: {
; Press down the Hyper modifiers
Send "{LCtrl down}{LAlt down}{LShift down}{LWin down}"
; Wait for Caps Lock to be released
KeyWait "CapsLock"
; Release the Hyper modifiers
Send "{LWin up}{LShift up}{LAlt up}{LCtrl up}"
; If no other key was pressed while Caps Lock was held down, fire Escape.
; (This inherently handles the tap behavior without needing a strict 500ms timer,
; but acts identically to your Karabiner setup).
if (A_PriorKey = "CapsLock") {
Send "{Esc}"
}
}
@Benjaminlooi
Copy link
Copy Markdown
Author

Windows AutoHotkey v2 script to replicate standard Karabiner-Elements developer keybinds:

  • Tap Caps Lock: Escape
  • Hold Caps Lock: Hyper Key (Ctrl + Alt + Shift + Win)
  • Shift + Caps Lock: Toggle normal Caps Lock state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment