Hold down a gamepad button (:down)
This method is available in versions after 20260805
Declaration
success, err = pad:down(button)
Parameters
- button
Integer or string. An integer from
1through32, one of the names below, or"start"or"menu"; string matching is case-insensitive
| Number | Button name | Aliases |
|---|---|---|
| 1 | a | - |
| 2 | b | - |
| 3 | x | - |
| 4 | y | - |
| 5 | left_shoulder | left_bumper, lb, l1 |
| 6 | right_shoulder | right_bumper, rb, r1 |
| 7 | left_trigger | lt, l2 |
| 8 | right_trigger | rt, r2 |
| 9 | left_stick | l3 |
| 10 | right_stick | r3 |
| 11 | l4 | left_paddle |
| 12 | r4 | right_paddle |
| 13 | m1 | - |
| 14 | m2 | - |
| 15 | m3 | - |
| 16 | m4 | - |
Returns
- success Boolean. True if the operation succeeds; false if the device is disconnected or busy, or if input delivery fails
- err String. Error message when the operation fails
Description
- Numeric values
1through32identify numeric buttons rather than button codes standardized across devices. Prefer the names in the table when possible - Numeric buttons
17through32have no predefined names and only have an effect when the target app supports the corresponding extended buttons "start"and"menu"are aliases for the same menu input and do not correspond to a numeric button from1through32- The names
select,back,options,home,share, and touchpad buttons are not currently supported left_triggerandright_triggersupport only pressed or released states, not analog pressure.menudoes not trigger the system Home action- Invalid argument types, unknown names, and out-of-range values raise Lua argument errors instead of returning
false, error
Example
local pad = assert(gamepad.connect())
assert(pad:down("left_shoulder"))
assert(pad:up("left_shoulder"))
assert(pad:down(13)) -- numeric button 13
assert(pad:up(13))
assert(pad:disconnect())