USBConnectionEvent
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The USBConnectionEvent interface of the WebUSB API is the event type passed to USB connect and disconnect events when the user agent detects that a new USB device has been connected or disconnected.
Constructor
USBConnectionEvent()-
Returns a
USBConnectionEventobject.
Instance properties
USBConnectionEvent.deviceRead only-
Returns a
USBDeviceobject representing the current device.
Examples
In the following example listening for connect and disconnect events is used to add and remove the devices from the user interface of an application.
navigator.usb.addEventListener("connect", (event) => {
// Add event.device to the UI.
});
navigator.usb.addEventListener("disconnect", (event) => {
// Remove event.device from the UI.
});
Specifications
| Specification |
|---|
| WebUSB API # usbconnectionevent |
Browser compatibility
| desktop | mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
USBConnectionEvent
|
|
|
|
|
|
|
|
|
|
|
|
|
USBConnectionEvent() constructor
|
|
|
|
|
|
|
|
|
|
|
|
|
device
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Available in workers
|
|
|
|
|
|
|
|
|
|
|
|
|
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- Experimental. Expect behavior to change in the future.
- See implementation notes.
- Has more compatibility info.