web api event
HID: disconnect event
Secure contextLimited availabilityAvailable in workers
The disconnect event of the HID interface fires when the user agent disconnects a HID device.
Syntax
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("disconnect", (event) => { })
ondisconnect = (event) => { }
Event type
A HIDConnectionEvent. Inherits from Event.
Examples
In the following example an event listener is registered to listen for the disconnection of a device. The name of the device is then printed to the console using productName.
navigator.hid.addEventListener("disconnect", ({ device }) => {
console.log(`HID disconnected: ${device.productName}`);
});
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.