Toggle to hold down not releasing key

Ask gaming related questions (AHK v1.1 and older)
Ophidahlia
Posts: 5
Joined: 09 Mar 2020, 16:01

Toggle to hold down not releasing key

09 Mar 2020, 16:25

I'm gaming with only one hand and need to get one of my mouse buttons to toggle shift when pressed. I'm using:

xbutton2::
toggle := !toggle

if toggle
Send {LShift down}
else{
Send {LShift up}

return

Which will hold down the shift key but will not release it until I actually press the shift key itself regardless of toggle state (you can tell it's toggling because I have to push xbutton2 twice to toggle it back to on). {LShift up} doesn't actually seem to let go of the key press. It does the exact same thing with Ctrl.

Any insight would be appreciated. Would it be easy to just send a single LShift keypress after it's toggled off again?
Rohwedder
Posts: 7768
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Toggle to hold down not releasing key

10 Mar 2020, 08:31

Hallo,
try:

Code: Select all

*XButton2 Up::Send,% GetKeyState("LShift")?"{LShift Up}":"{LShift DownR}"
or:

Code: Select all

#InstallKeybdHook
XButton2 Up::Send, {LShift DownR}
<+XButton2 Up::Send, {LShift Up}
Ophidahlia
Posts: 5
Joined: 09 Mar 2020, 16:01

Re: Toggle to hold down not releasing key

16 Mar 2020, 13:07

Thanks Rohwedder, that works just fine!

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: mexican scientist and 72 guests