Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HIDConnectionEvent

HIDConnectionEvent

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.

TheHIDConnectionEvent interface of theWebHID API represents HID connection events, and is the event type passed toconnect anddisconnect event handlers when a device's connection state changes.

Event HIDConnectionEvent

Constructor

HIDConnectionEvent()Experimental

Returns a newHIDConnectionEvent object. Typically this constructor is not used as events are created when a device's connection state changes.

Instance properties

This interface also inherits properties fromEvent.

HIDConnectionEvent.deviceRead onlyExperimental

Returns theHIDDevice instance representing the device associated with the connection event.

Examples

The following example registers event listeners forconnect anddisconnect events, then prints theHIDDevice.productName to the console.

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

Specifications

Specification
WebHID API
# dom-hidconnectionevent

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp