Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HID
  4. connect

HID: connect event

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

Note: This feature is available inWeb Workers, except forShared Web Workers.

Theconnect event of theHID interface fires when the user agent connects to a HID device.

Syntax

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

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

Event type

AHIDConnectionEvent. Inherits fromEvent.

Event HIDConnectionEvent

Event properties

In addition to the properties listed below, properties from the parent interface,Event, are available.

deviceRead only

TheHIDDevice the event is fired for.

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 usingHIDDevice.productName.

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

Specifications

Specification
WebHID API
# dom-hid-onconnect

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp