Skip to content

Instantly share code, notes, and snippets.

@pirey
Last active May 21, 2024 10:05
Show Gist options
  • Save pirey/79442f230d77d0e067677261101adc58 to your computer and use it in GitHub Desktop.
Save pirey/79442f230d77d0e067677261101adc58 to your computer and use it in GitHub Desktop.
autohotkey script to remap capslock as both control and escape key.
; Remap Caps Lock to Ctrl
Capslock::Ctrl
; Remap Ctrl + [ to Escape
^[::
Send, {Escape}
return
; Remap Escape to Caps Lock
Escape::Capslock
; Change Caps Lock to Control when held down; otherwise, Escape
;
; Originally based on the answer provided in
; [this](https://superuser.com/questions/581692/remap-caps-lock-in-windows-escape-and-control)
; StackExchange SuperUser question.
;
; A shortcut should be created for this script and placed in the Windows 10
; user's startup folder to automatically enable the feature on boot/startup.
; The user's startup folder can be found using the following steps:
;
; 1. Windows Key+R. The _Run_ dialog will appear.
; 2. Enter the following: `%appdata%\Microsoft\Windows\Start Menu\Programs\Startup`
; 3. Press Enter key. A file explorer dialog will appear.
;
; Obviously, [AutoHotkey](https://autohotkey.com/) must be installed for this to work.
*CapsLock::
Send {Blind}{Ctrl Down}
cDown := A_TickCount
Return
*CapsLock up::
; TODO: prevent send {Esc} after another key has been pressed.
If ((A_TickCount-cDown)<100) ; Modify press time as needed (milliseconds)
Send {Blind}{Ctrl Up}{Esc}
Else
Send {Blind}{Ctrl Up}
Return
@pirey
Copy link
Author

pirey commented May 15, 2023

@pirey
Copy link
Author

pirey commented May 15, 2023

Not sure why but the script for ahk v1 is more consistent than v2 script.

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