USBConnectionEvent.USBConnectionEvent()

Secure context

This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The USBConnectionEvent() constructor creates a new USBConnectionEvent object which is passed to USB.onconnect and USB.ondisconnect. This constructor is not typically used, it is created by the browser in response to the connection and disconnection of a USB device.

Syntax

new USBConnectionEvent(type, USBConnectionEventInit);

Parameters

type
A string representing the name of the event. One of:
  • connect
  • disconnect
USBConnectionEventInit
An object including the following:
A USBDevice
An object representing the USB device being connected or disconnected.
bubbles Optional
A Boolean indicating whether the event bubbles. The default is false.
cancelable Optional
A Boolean indicating whether the event can be cancelled. The default is false.
composed Optional
A Boolean indicating whether the event will trigger listeners outside of a shadow root (see Event.composed for more details). The default is false.

Specifications

Specification Status Comment
WebUSB
The definition of 'USBConnectionEvent()' in that specification.
Draft Initial definition.

Browser compatibility

No compatibility data found for api.USBConnectionEvent.USBConnectionEvent.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.