Firefox Tomorrow

web api event

USB: disconnect event

View on MDN ↗

Limited availabilitySecure contextAvailable in workers

The disconnect event of the USB interface is fired whenever a paired device is disconnected.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener("disconnect", (event) => { })

ondisconnect = (event) => { }

Event type

A USBConnectionEvent. Inherits from Event.

Examples

Once a USB device is disconnected, you might want to update the UI.

navigator.usb.addEventListener("disconnect", (event) => {
  // Remove event.device from the UI.
});

Alternatively, you can use the USB.ondiscconnect event handler property to establish a handler for the disconnect event:

navigator.usb.ondisconnect = (event) => {
  // Remove event.device from the UI.
};

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.