Browse the docs

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 #

ParameterTypeRequiredValuesWhat it does
actionone ofdown updown or up. The default is down. Any other value fails.
buttonone ofleft right middleleft, right or middle. The default is left.
releaseAfternumberSeconds 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:

Send a left mouse-up (really sends the event)
Do
  1. Release the left mouse button
  2. Show “Mouse button released”
Open in Switchboard to try it

Gotchas #

  • Needs Accessibility permission, otherwise the step fails with "Accessibility isn't allowed for Switchboard Engine".

  • Always pair down with an up. The automatic release after releaseAfter is a safety net.

  • Only the left and right buttons are supported.

  • Steps that touch the Mac are simulated in a dry run.

See also #

Click, Drag mouse, Move pointer by, Press or hold modifiers