Hold or release mouse button
Presses a mouse button down at the pointer and holds it, or lets it go.
action the button mouse button
Keyboard Maestro: MouseMoveAndClick
Details #
Sends a mouse-down or mouse-up for the left, right or middle button at wherever the pointer is now. It is the building block for hand-made drags and press-and-hold: put the button down, do other steps such as Move pointer by, then send up.
The output holds the button and the action. For a plain click use Click; for a drag from one place to another use Drag mouse.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
action | one of | down up | down or up. The default is down. Any other value fails. | |
button | one of | left right middle | left, right or middle. The default is left. | |
releaseAfter | number | Seconds after which a held button is let go automatically if you never send up. The default is 60, and values under 1 count as 1. Only used with down. |
Every step also accepts label, onFailure, timeout and dryRunSafe.
Examples #
Releasing a button that isn't down is harmless, so this is a safe thing to try. Run for real it sends a left-button up at the pointer:
- Release the left mouse button
- Show “Mouse button released”
Gotchas #
Needs Accessibility permission, otherwise the step fails with "Accessibility isn't allowed for Switchboard Engine".
Always pair
downwith anup. The automatic release afterreleaseAfteris a safety net.Only the left and right buttons are supported.
Steps that touch the Mac are simulated in a dry run.