Skip to main content

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 true while the object is connected and available for use, and false after 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)