Firefox Tomorrow

web api instance method

HIDDevice: open() method

View on MDN ↗

Secure contextLimited availabilityAvailable in workers

The open() method of the HIDDevice interface requests that the operating system opens the HID device.

[!NOTE] HID devices are not opened automatically. Therefore, a HIDDevice returned by requestDevice() must be opened with this method before it is available to transfer data.

Syntax

open()

Parameters

None.

Return value

A Promise that resolves with undefined once the connection is opened.

Exceptions

  • InvalidStateError DOMException
    • : Thrown if the connection is already open.
  • NotAllowedError DOMException
    • : Thrown if the attempt to open the connection fails for any reason.

Examples

In the following example, we wait for the HID connection to open before attempting to send or receive data.

await device.open();

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.