windowskeyboard-shortcutsautohotkeykey-bindings

How to map CapsLock to Esc and Ctrl in Autohotkey?


How to remap Capslock key in a way that pressing and releasing it registers as Escape key but pressing and holding it registers as Ctrl key modifier?

I'm looking for a windows solution preferably using Autohotkey v2.


Solution

  • #Requires AutoHotkey v2.0
    
    ; Remap Capslock to Ctrl:
    Capslock::Ctrl  
    
    Capslock Up::{
        Send "{Ctrl Up}"
        If (A_PriorKey = "Capslock") ; if Capslock was pressed alone
            Send "{Esc}"
    }