Press or hold modifiers
Taps, holds or releases modifier keys such as Command, Option, Control, Shift and Fn on their own.
action modifiers
Keyboard Maestro: SimulateModifiers, ApplyModifiersToApplication
Details #
Presses a modifier key without any other key. Use it for a click or drag that needs a key held down, or for apps that react to a bare modifier. For ordinary shortcuts use Press keys.
action says what to do:
press (the default) taps the modifiers: down, a 0.05 second pause, up.
hold presses them and keeps them down.
release lets go of them.
modifiers can be a list, ["cmd", "shift"], or text such as "cmd+shift" or "⌘⇧". The accepted words are cmd / command, opt / option / alt, ctrl / control, shift, fn / function and hyper (Command, Control, Option and Shift together). An empty list does nothing.
The output holds the modifiers that were used.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
action | one of | press hold release | press, hold or release. The default is press. Any other value fails. | |
app | text | Bring this app to the front first (it is not launched if it isn't running). Ignored for release. | ||
modifiers | any value | The keys, as a list or as text (see above). An unknown word fails with "isn't a modifier (cmd, opt, ctrl, shift, fn)". |
Every step also accepts label, onFailure, timeout and dryRunSafe.
Examples #
Tapping Shift alone does nothing visible in most apps, which makes it a safe thing to try. Run for real, it presses the key:
- Tap ⇧
- Show “Tapped Shift”
Gotchas #
Needs Accessibility permission, otherwise the step fails with "Accessibility isn't allowed for Switchboard Engine".
A held modifier is let go by itself after 60 seconds. Always pair
holdwith areleasestep anyway.While a modifier is held it affects everything you type or click, not only the macro's steps.
Steps that touch the Mac are simulated in a dry run.