类型 字符串 物件 InputDevice 修订版本 发布 2024.3703 关键字 设备、输入、displayName
由系统或终端用户赋予输入设备的名称。可用于向终端用户显示设备名称,例如在键/按钮绑定画面上。
在 Android 上,此名称将是制造商指定的產品名称,除非终端用户通过 Android 的 Bluetooth 设置畫面进行更改。
-- Called when a key event has been received. local function onKeyEvent( event ) -- Fetch the device's display name. -- Note: The "device" property will be nil if the platform does not support input devices -- or if input came from software, such as a virtual keyboard. local deviceName = "Unknown Device" if event.device then deviceName = event.device.displayName end -- Print device information to the log. print( deviceName .. ": Pressed the '" .. event.keyName .. "' key " .. event.phase ) end -- Set up the above function to receive key events. Runtime:addEventListener( "key", onKeyEvent )