HIDDevice: sendFeatureReport() method

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 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 sendFeatureReport() method of the HIDDevice interface sends a feature report to the HID device. Feature reports are a way for HID devices and applications to exchange non-standardized HID data.

The reportId for each of the report formats that this device supports can be retrieved from HIDDevice.collections.

Syntax

js
sendFeatureReport(reportId, data)

Parameters

reportId

An 8-bit report ID. If the HID device does not use report IDs, send 0.

data

Bytes as an ArrayBuffer, a TypedArray, or a DataView.

Return value

A Promise that resolves with undefined once the report has been sent.

Exceptions

NotAllowedError DOMException

Thrown if sending the report fails for any reason.

Examples

In the following example sendFeatureReport() makes a device blink. You can see more examples and live demos in the article Connecting to uncommon HID devices.

js
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));
}

Specifications

Specification
WebHID API
# dom-hiddevice-sendfeaturereport

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
sendFeatureReport
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.