Firefox Tomorrow

web api event

HID: connect event

View on MDN ↗

Secure contextLimited availabilityAvailable in workers

The connect event of the HID interface fires when the user agent connects to a HID device.

Syntax

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

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

onconnect = (event) => { }

Event type

A HIDConnectionEvent. Inherits from Event.

Examples

In the following example an event listener is registered to listen for the connection of a device. The name of the device is then printed to the console using productName.

navigator.hid.addEventListener("connect", ({ device }) => {
  console.log(`HID connected: ${device.productName}`);
});

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.