Skip to main content

Disconnect a hardware keyboard (:disconnect)

This method is available in versions after 20260805

Declaration

success, err = keyboard:disconnect()

Returns

  • success Boolean. Returns true after successful disconnection and false on failure.
  • err String. Error message returned when disconnection fails.

Description

Releases all keys and disconnects this hardware keyboard object.

  • This method may be called repeatedly.
  • If the object is the current global hardware keyboard, this method also clears the global keyboard connection.
  • If the same hardware keyboard is running a :press or :send_text sequence, this method returns false, "hardware keyboard is busy".
  • When Lua collects a hardware keyboard object or the script stops, XXTouch also releases all keys and disconnects the object.

Example

local keyboard = assert(key.connect_keyboard())

local success, err = keyboard:disconnect()
assert(success, err)