Page 1 of 1

How to use CapsLock as a modifier key in ahk v2  Topic is solved

Posted: 21 Jan 2024, 17:48
by iseahound
There's a few variants of this code posted on this forum. Just wanted to make it easier to find for everyone. The goal is to turn CapsLock into a proper modifying key, and not do simple combos like CapsLock & q:: MsgBox.

The good part about this is that the CapsLock functionality is preserved. Just double click CapsLock!

Code: Select all

CapsLock:: {
   start := A_TickCount                              ; run once
   KeyWait('CapsLock')                               ; wait for Capslock to be released
   if (A_TickCount - start < 200)                    ; in 0.2 seconds
   and KeyWait('CapsLock', 'D T0.2')                 ; and pressed again within 0.2 seconds
   and (A_PriorKey = 'CapsLock')                     ; block other keys
      SetCapsLockState !GetKeyState('CapsLock', 'T')
}
*CapsLock:: return                                   ; This forces capslock into a modifying key.

#HotIf GetKeyState("CapsLock", "P")
Alt::  return                                        ; Disables Alt menu when CapsLock + Alt is pressed.
LWin:: return                                        ; Suppresses the Start Menu.
RWin:: return

; ---- Your hotkeys go here! ----

q:: MsgBox "You pressed CapsLock + q"
^w:: MsgBox "You pressed CapsLock + Control + w"
#HotIf

Re: How to use CapsLock as a modifier key in ahk v2

Posted: 03 Feb 2024, 05:04
by submeg
Just wanted to make it easier to find for everyone
Can this be pinned somewhere?

I've been making mods to this script by Skommel - CapShift. Very nice!

Re: How to use CapsLock as a modifier key in ahk v2

Posted: 04 Jun 2024, 14:16
by iseahound
mini update where I added the below code to block the Windows Start menu and the Alt bar from appearing.

Code: Select all

Alt::  return                                        ; Disables Alt menu when CapsLock + Alt is pressed.
LWin:: return                                        ; Suppresses the Start Menu.
RWin:: return