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 in secure contexts (HTTPS), in some or all supporting browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Note: This feature is available in Web Workers, except for Shared Web Workers.
The HIDDevice interface of the WebHID API represents a HID Device. It provides properties for accessing information about the device, methods for opening and closing the connection, and the sending and receiving of reports.
This interface also inherits properties from EventTarget.
HIDDevice.opened Read only Experimental
Returns a boolean, true if the device has an open connection.
HIDDevice.vendorId Read only Experimental
Returns the vendorId of the HID device.
HIDDevice.productId Read only Experimental
Returns the productId of the HID device.
HIDDevice.productName Read only Experimental
Returns a string containing the product name of the HID device.
HIDDevice.collections Read only Experimental
Returns an array of report formats for the HID device.
inputreport Experimental
Fires when a report is sent from the device.
This interface also inherits methods from EventTarget.
HIDDevice.open() Experimental
Opens a connection to this HID device, and returns a Promise which resolves once the connection has been successful.
HIDDevice.close() Experimental
Closes the connection to this HID device, and returns a Promise which resolves once the connection has been closed.
HIDDevice.forget() Experimental
Closes the connection to this HID device and resets access permission, and returns a Promise which resolves once the permission was reset.
HIDDevice.sendReport() Experimental
Sends an output report to this HID Device, and returns a Promise which resolves once the report has been sent.
HIDDevice.sendFeatureReport() Experimental
Sends a feature report to this HID device, and returns a Promise which resolves once the report has been sent.
HIDDevice.receiveFeatureReport() Experimental
Receives a feature report from this HID device in the form of a Promise which resolves with a DataView. This allows typed access to the contents of this message.
The following example demonstrates listening for an inputreport event that will allow the application to detect which button is pressed on a Joy-Con Right device.
device.addEventListener("inputreport", (event) => {
const { data, device, reportId } = event;
// Handle only the Joy-Con Right device and a specific report ID.
if (device.productId !== 0x2007 && reportId !== 0x3f) return;
const value = data.getUint8(0);
if (value === 0) return;
const someButtons = { 1: "A", 2: "X", 4: "B", 8: "Y" };
console.log(`User pressed button ${someButtons[value]}.`);
});
In the following example sendFeatureReport is used to make a device blink.
const reportId = 1;
for (let i = 0; i < 10; i++) {
// Turn off
await device.sendFeatureReport(reportId, Uint32Array.from([0, 0]));
await new Promise((resolve) => setTimeout(resolve, 100));
// Turn on
await device.sendFeatureReport(reportId, Uint32Array.from([512, 0]));
await new Promise((resolve) => setTimeout(resolve, 100));
}
You can see more examples, and live demos in the article Connecting to uncommon HID devices.
| Specification |
|---|
| WebHID API> # dom-hiddevice> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
HIDDevice |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
close |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
collections |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
forget |
100 | 100 | No | 86 | No | No | No | No | No | No | No | No |
inputreport_event |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
open |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
opened |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
productId |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
productName |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
receiveFeatureReport |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
sendFeatureReport |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
sendReport |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
vendorId |
89 | 89 | No | 75 | No | No | No | No | No | No | No | No |
worker_support |
131Dedicated workers and WebExtension service workers, not shared workers and non-WebExtension service workers.117–131WebExtension service workers only. |
131Dedicated workers and WebExtension service workers, not shared workers and non-WebExtension service workers.117–131WebExtension service workers only. |
No |
116Dedicated workers and WebExtension service workers, not shared workers and non-WebExtension service workers.103–116WebExtension service workers only. |
No | No | No | No | No | No | No | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice