I'm wondering if there is a %Token% to represent the key that is just pressed.
I would like to perform a set of actions if the key is "Ctrl" but another set of actions if the key is "Left Arrow".
I know we could probably use two separate macros for this purpose. But if there is already a token or something else I can use within the same macro, it would be great. (Since Keyboard Maestro can detect keypress, I assume it's capable of doing this, but I don't know if a %Token% sort of thing is provided or not. )
Hi @tiffle,
Thanks. But this does not work. It is the typed string that triggers the macro, not the key monitored by the "Wait Until key press" action.
In the past I’ve approached this problem by performing tests in KM actions following the Pause action. You can see an example of this in this discussion
FYI, I would now not use nested IF actions, but instead I would use a Switch action which is much easier to maintain.
Hope this helps a bit more than my last suggestion.
Thanks. Your macro relies on the condition that when the IF THEN action is processed, the key is still down. Right? I tested it. It seems to be working pretty well. I don't need to press longer than I usually do for it to work.
I've never consciously pressed keys any longer than normal when using this method but then I've never stress-tested this approach.
That is another reason for using a Switch action - you can have an "otherwise" condition to catch all those instances (if any) when a key other than the ones you are looking for is pressed and deal with it sensibly; equally, you can put an IF action in the Otherwise condition to check whether the key is no longer being pressed, and deal with that if it should ever arise.