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 value indicating whether the event bubbles. The default is false.

cancelable Optional

A boolean value indicating whether the event can be cancelled. The default is false.

composed Optional

A boolean value indicating whether the event will trigger listeners outside of a shadow root (see Event.composed for more details). The default is false.

Specifications

Specification
WebUSB API
# dom-usbconnectionevent-usbconnectionevent

Browser compatibility

BCD tables only load in the browser