Pause until any number key stroke

Hi everyone!

I'm trying to do a very simple macro actually, but at certain point I need the macro to pause until I hit a key number between 0 and 9, and depending on what number I hit it would do one action or the other.

do you know how to tell keyboard maestro to wait until any keystroke?

Any hints?

Thanks for the help

Well I use the brute force method of doing what you're asking - see here:

The macro is self-explanatory and there may be far more elegant ways of doing this but until someone else suggests an alternative, you could try this!

[LIB]_Key Pad N.kmmacros (21.2 KB)

Hope this helps and good luck!

Unfortunately the Pause Until action does NOT allow for a condition of a keystroke that matches a typed string, which we need for matching any digit: \d.

So, we need to use a set of macros to achieve this, with Macro 2 being set to trigger by the typed string matching \d, which will match any single digit from 0-9.

Important Notes

  1. Macro 2 will be uploaded in a DISABLED state. Leave it disabled. It will be enabled as needed by Macro 1.
  2. Macro 2 uses a Typed String trigger. It should only be triggered when you are in a document/field that supports typing text.

Here are the example macros.
You will need to modify, or use as an example, to work as your production workflow macro.

Let us know if this works for you.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Macro 1 - Pause Until a Digit is Typed [Example]

**Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/8/7/879c4cdc459c979d20ff118f932b65bab99ad8df.kmmacros">Macro 1 - Pause Until a Digit is Typed [Example].kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

### Release Notes
1. This is the MAIN that performs all of the work of your workflow
2. It uses Macro 2 (below) to work with its _Pause Until_ in order to pause until any digit is typed.
3. The Switch Case Action is only filled out for digits 0-3 as an example.
   * You will need to ADD the remaining cases for digit 4-9.

---


<img src="/uploads/default/original/3X/a/c/ac081b73dc31b400bbd559fceb5b96fba3fe7d63.png" width="569" height="1907">

`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

### MACRO:&nbsp;&nbsp;&nbsp;Macro 2 -- Trigger When a Digit is Typed [Example]

~~~ VER: 1.0&nbsp;&nbsp;&nbsp;&nbsp;2020-01-20 ~~~
**Requires: KM 8.2.4+&nbsp;&nbsp;&nbsp;macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/b/1/b1fed4b83a83a85fed22670a8809fac80909f94b.kmmacros">Macro 2 -- Trigger When a Digit is Typed [Example].kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. Leave it Disabled.  It will be enabled by Macro 1 above as needed.**


---


<img src="/uploads/default/original/3X/7/4/74ba6322c924f03a7b8699a17c250185c078ef2e.png" width="569" height="488">
1 Like

Woooow, thank you very much to all, it really help!