Autohotkey capslock remapping and use as a modifier

By default AutoHotKey only enables a hotkey if that exact combination of keys is pressed, no variation allowed. To achieve the "select one line below" effect, you should be using the * wildcard modifier which makes the hotkey work even if extra keys are pressed, like this:

#persistent
SetCapsLockState, AlwaysOff
*CapsLock::Esc

*Capslock & j::Send {Blind}{Down DownTemp}
*Capslock & j up::Send {Blind}{Down Up}

Read more about it here: https://www.autohotkey.com/docs/Hotkeys.htm#wildcard

Also, if you would like to use a modifier key on multiple hotkeys (like CapsLock in you case) I would recommend combining the #If environment with the GetKeyState command like you can see in my script that I use to turn some keys into arrows while a button is pressed down and many more extras.

https://gist.github.com/Isti115/0b657e7d0a50c96dd3806e86951f5421


Edit: Hmm, it seems like the asterisk shouldn't be necessary for combined keys. The documentation: https://www.autohotkey.com/docs/Hotkeys.htm#combo_mods says that Unlike a normal hotkey, custom combinations act as though they have the wildcard (*) modifier by default., but in this case I don't really understand why your version did not work.


In case anyone else stumbles upon this question, here's another way to do this that prevents all accidental Caps Lock toggling:

SetCapsLockState, AlwaysOff

#If GetKeyState("CapsLock", "P")
h::Left
j::Down
k::Up
l::Right
#If

*CapsLock::
KeyWait, CapsLock
IF A_ThisHotkey = *CapsLock
    Send, {Escape}
Return

Credit Rohwedder: https://www.autohotkey.com/boards/viewtopic.php?t=70880