Pause until key press?

Is there any way to pause until any key is pressed?

Hey Mitchell,

Yep.

-Chris


Generic-Test 01.kmmacros (2.0 KB)

any key, that is, not “some key (that I need pressed)” but “any key pressed”. Ambiguous, true.

Hey Mitchell,

Ah, I missed the subtlety...

I'm not aware of a means to use any key.

-Chris

I suppose a Typed String trigger configured for regex “.” without deleting and not doing anything except setting a variable would work.

It still wont detect any key, it’ll detect normal key strokes, but not things like function keys or arrows, not sure about return and such (maybe “(?s).” might detect returns).

So the process would be:

  • Set variable “Any Key Pressed” to 0
  • Enable Macro “Trigger on regex .”
  • Pause Until “Any Key Pressed” is not 0
  • Disable Macro “Trigger on regex .”
1 Like

Would “Pause for Any Key is Pressed/Released” be hard to implement?

The Keyboard Maestro Conditions are based on state, not transitions.

So there are no Pause Until [state change] options (clipboard changed, window changed, key state changed, modifiers changed, mouse moved, etc).

It is possible there could be, but there are no options to do that currently except by creating them yourselves.

I would really like the 'pause until any keystroke' ability.
What would the "Trigger on regex ." Macro be?

Triggering a macro and pausing a macro are two completely different things.
Which do you want to do?

to pause a currently running macro until any keystroke is made.
I have a user input box up and once I type 1 letter in there I would like it to continue.
And also capture that key to the assigned variable in the user input dialog.

OK, given that you want to also capture the keystroke, it may be simpler, better, to use something like this:

  • MACRO A

    • The initial macro that starts your workflow.
    • Does whatever you want until you want it to "pause" for any keystroke.
    • Then it would enable Macro B, and exit.
  • MACRO B

    • Is initially disabled, until enabled by Macro A.
    • Has a typed string trigger of \.
      • If you can restrict your keystroke to letters or numbers that would be better
      • You could then use \w (any letter or number)
    • As soon as you type a keystroke, this macro is triggered.
    • The key pressed is in the token %TriggerValue%
    • Do whatever processing you need with it
    • Then disable this macro as the last Action

There may be other, better, approaches.

How does that sound?

I must be missing something here.
Is the screenshot correct? Per your advice


What I would like is for the following macro to run, wait for user input, and once a keystroke is performed it would capture that keystroke to a variable and continue with the rest of the script. (in this case typing an 'enter' to dismiss the onscreen dialog and then continuing.
I'm sure there are a lot of other ways to do what I want to as far as the act of executing a screen share, but my goal is to learn the use of KM in this exercise, and I use a fair amount of 'wait for keystroke' then continue approaches. So it's not just about executing this screen share, it's about the process of the 'wait for keystroke' and capturing that keystroke

my mistake and inexperience,
I didn’t select 'regular expression match’
it works now in general.
but does not work if there is a user input dialog on screen.
I’d like to have it work capturing the keystroke entered in the user input dialog
and then continue the macro.

I would now like to 'Pause until any keystroke' within a macro. - I'm sure it's possible but don't 'see' it easily.

I think your question has been answered in the above posts, particularly:

As clearly stated by @peternlewis:

But I think you are making this unduly hard on yourself. Why not just wait for a large, easy to reach key is pressed? Oh yeah, we have one. The SPACEBAR:

image

The SHIFT key is also a favorite, so you could add it:

image

Of course, you could just keep adding The key conditions until you have all of them entered, but what mess. :wink:

I need to wait for 2 characters in this macro, it could be 2 digits or 2 letters or 1 of each, I need the macro to wait until 2 keys, any keys are typed, then continue.
I understand the Macro A and Macro B example given above.
Is there no way to have it self contained in one macro where one of the actions is to
'pause for any keystroke' ?
Thank you as always for your time.

What's wrong with this? Requires two keys: SPACE and Z:

image

Pick any two characters you want.

The characters will vary every time
it could be 12, then it could be zp, then it could be 1p
it needs to wait for any, 2 keys to be typed, not a pre-determined 2 keys.
Apologies if I was not clear.

Why are the two characters being typed?
If they are doing something else, then use a single, 3rd character that is fixed to work with the pause until. I often use CTRL RETURN or OPT RETURN, but you pick it.

1 Like

right =), designated 3rd character, duh! fair enough.
any two characters, followed by static 3rd character.
I was locked into my old Quickeys head. It had a step 'wait for any key to be typed'.
I used it a lot.
Thank you again.