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
1through32or one of the button names below. Strings are case-insensitive.
Returns
- success
Boolean.
trueif the button is pressed successfully; otherwisefalse. - error_message String. The reason the operation failed.
Description
Button numbers range from
1through32. Values outside this range raise a Lua argument error.
| Name | Number |
|---|---|
left | 1 |
right | 2 |
middle | 3 |
back | 4 |
forward | 5 |
Buttons 1, 2, and 3 usually represent the left, right, and middle buttons.
backandforwardare 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())