Trigger an action when both left and right shift keys are down

132 views Asked by At

I wish to trigger a custom action once, when both shift keys are down. So if I press left shift and then right shift while the left one is down the action should trigger once.

I have no problem coding the script, the issue is that RShift and LShift don't behave like normal keys. They refuse to be detected by GetKeyState, so the dynamic solution is out, since I can't pool the state in a loop and check if both keys are down. ( I would prefer to avoid looping in favor of a static hotkey solution though )

If I defined the hotkeys like this:

~RShift::
    tooltip, right
return 

~LShift::
    tooltip, left   
return 

The pressing RShift triggers the tooltip, but pressing LShift afterwards doesn't do anything, so I'm again stuck without any functionality to code my solution.

~ is there to preserve the original behavior of shift keys, which I need.

I have also experimented with prefixes $,+, and * without success.

I would entertain any advice on this matter.

1

There are 1 answers

0
bgoldst On BEST ANSWER

I've never done this myself, but it looks to me like you can use the ampersand to specify both modifier keys in the hotkey. Unfortunately, it looks like you have to specify both orders, since order seems to matter here, but it's not such a hardship:

~RShift & ~LShift::
~LShift & ~RShift::
    MsgBox a
return