Macro Trigger Option Using Long Press of Hot Key [Example]

MACRO: Trigger Option Using Long Press of HotKey [Example]

VER: 1.0      2016-07-30 ~~~~~


Trigger Option Using Long Press of HotKey [Example].kmmacros (12 KB)


• Demonstrate how to make use a long press of the hot key trigger to invoke optional processing in your macro
• This NOT a finished macro, ready for use in a production environment
• It is a teaching example to show you how to use this concept in your own macros.

Author: @JMichaelTX, @Tom, @DanThomas, others
• While I wrote this specific macro, the original idea/example was
posted by @Tom, and then @DanThomas. (see references below)
• Others may have pioneered this idea

(1) Normal Use: Quickly press and release the Hot Key
(2) Optional Use: Press and hold Hot Key trigger for at least 0.5 sec
• You should hear a brief "Tink" sound

Macro Setup

  • Change the Macro Hot Key Trigger to whatever you'd like
  • Then change the Action "CHECK FOR LONG PRESS" to use the same key and modifier key


• This macro: Macro Trigger Option Using Long Press of Hot Key [Example]
@Tom: Select All and Copy
@DanThomas: MACRO: Run Current Macro

Example Results


Some more examples:


This is pretty slick, thanks for posting!

There is a tiny mistake: The first IF statement condition is “All of the following are true”

It not really a mistake, just a design choice.
As it, it will be true if EITHER the main key OR the modifier key are down. This just makes it easier to use.

Oh~ That makes sense.


as many of you probably noticed the script had an issue when e.g. you pressed quickly the "Trigger" multiple times after one another, e.g.:

Short Press -> Release -> Long Press (Hold) (all within the 0.5 second pause period) would recognize only one long press. Preferred would be that it recognized one short press and then one long press.

Happily Keyboard Maestro introduced in Version 9 a new option being able to access the unique ID of a script instance ( which can be used in order to prevent the above described issue.

Please find here a modified "Version 2" of above script:

Trigger Option Using Long Press of HotKey v2.0 [Example].kmmacros (21.2 KB)


1 Like