I want to toggle holding a key down (q) by pressing it while I'm already physically holding a different key down (w), and then untoggle (release) that key (q) when I let go of the key I'm actually holding down (w).
So I'll be already holding W down, then I want to just press Q to toggle holding down Q, but then Q releases itself when I let go of W.
This is to enable toggling of a run/sprint key in an FPS, but not have to press that key again to untoggle it (the sprint will be disabled when I stop moving forward). This mimics the toggle sprint behavior of games that natively support it (the game I'm playing now does not offer sprint toggle).
I know the following code works for toggling the key down on pressing it, but I want it to release when I physically release the other key (w).
Code: Select all
q::
KeyDown := !KeyDown
If KeyDown
SendInput {q down}
Else
SendInput {q up}
Return