Hold down a hardware keyboard key (:down)
This method is available in versions after 20260805
Declaration
success, err = keyboard:down(key)
success, err = keyboard:down(usage_page, usage_id)
Parameters
- key
String. Uses the same key-name mapping as
key.press. - usage_page
Integer. Hardware keyboard objects currently accept only Keyboard/Keypad Usage Page
0x07. - usage_id Integer. Physical key identifier, not a character encoding.
Returns
- success
Boolean. Returns
truewhen the key is held successfully andfalseon failure. - err String. Error message returned when sending fails.
Description
Hold down a hardware keyboard key. Call the corresponding
:upafterwards to release it.
- If the same keyboard is running a
:pressor:send_textsequence, this method returnsfalse, "hardware keyboard is busy". - At most six non-modifier keys can be held at once; modifier keys do not count toward this limit.
- On failure, the method returns
falseand an error message. It is not retried through another input method.
Example
local keyboard = assert(key.connect_keyboard())
assert(keyboard:press(0x07, 4)) -- Keyboard A
assert(keyboard:down(0x07, 0xE1)) -- Left Shift
assert(keyboard:up(0x07, 0xE1))
assert(keyboard:disconnect())