Skip to main content

Press a hardware mouse button (:down)

This method is available in versions after 20260805

Declaration​

success, error_message = mouse_obj:down(button)

Parameters​

  • button
    Integer or string. Pass a value from 1 through 32 or one of the button names below. Strings are case-insensitive.

Returns​

  • success
    Boolean. true if the button is pressed successfully; otherwise false.
  • error_message
    String. The reason the operation failed.

Description​

Button numbers range from 1 through 32. Values outside this range raise a Lua argument error.

NameNumber
left1
right2
middle3
back4
forward5

Buttons 1, 2, and 3 usually represent the left, right, and middle buttons. back and forward are aliases for Buttons 4 and 5. Buttons 6 through 32 have no fixed names, and their behavior depends on iOS and the target app. Some apps may receive only the first five buttons.

Example​

local m = assert(mouse.connect())
assert(m:down("left"))
assert(m:up("left"))
assert(m:down(13))
assert(m:up(13))
assert(m:disconnect())