HIDConnectionEvent: device property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
Note: This feature is available inWeb Workers, except forShared Web Workers.
Thedevice read-only property of theHIDConnectionEvent interface returns theHIDDevice associated with this connection event.
In this article
Value
Examples
The following example registers event listeners forconnect anddisconnect events, then prints theHIDDevice.productName to the console.
js
navigator.hid.addEventListener("connect", ({ device }) => { console.log(`HID connected: ${device.productName}`);});navigator.hid.addEventListener("disconnect", ({ device }) => { console.log(`HID disconnected: ${device.productName}`);});Specifications
| Specification |
|---|
| WebHID API> # dom-hidconnectionevent-device> |