If left option is pressed do X, otherwise do Y: is that possible?

I have a macro that is assigned to a palette. Now I want to let this macro check for the status of the left option key: if it is pressed, it should perform action X, if it's not pressed, it should perform action Y. Is this possible?

You could perhaps do it like this..?

Macro 1

Trigger = the left option key of the USB device is pressed (as shown in your post).
Action: set global variable left_option_key to "true".

Macro 2

Trigger = the left option key of the USB device is released
Action: set global variable left_option_key to "false".

Macro 3 – your main macro

Trigger = palette
Action: check whether left_option_key is true or false and branch to other actions accordingly.

1 Like

Notes:

  • Depending on your needs, left_option_key might not need to be global.
  • In accordance with my preferred practice, I would actually name the variable as global left_option_key . :wink:
1 Like

That isn't checking for status -- it's using leftOption as a trigger.

How do you want to actually trigger the macro? By clicking on the palette icon, or something else?

Yes, by clicking on the palette icon. I'll try @kevinb's suggestion first.

Then this may not work -- Option-clicking a macro icon in a palette takes you to that macro in KM, ready to edit it. I don't know if you can turn that feature off?

If you can, or if you want to use a different modifier key instead, then any keys down will be available via the %TriggerValue% token in the usual way.

1 Like

Although using the Option key would be more intuitive, its use is not critical. So I decided to switch to the Escape key, which is a nice, big key whose position is hardwired into my muscle memory. Now things are simpler: