Check whether a hardware keyboard is connected (:is_connected)
This method is available in versions after 20260805
Declaration
connected = keyboard:is_connected()
Returns
- connected
Boolean. Returns
truewhile the object is connected and available for use, andfalseafter disconnection.
Description
Get the connection state of the current hardware keyboard object.
After a global hardware keyboard is disconnected, Lua variables may still hold the original object, but this method returns false and key.get_global_keyboard returns nil.
Example
local keyboard = assert(key.connect_keyboard())
local connected = keyboard:is_connected()
local properties = keyboard:get_properties()
local success, err = keyboard:disconnect()
assert(success, err)