-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
38 lines (27 loc) · 920 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
title: "HIDDevice: opened property"
short-title: opened
slug: Web/API/HIDDevice/opened
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.HIDDevice.opened
---
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}}
The **`opened`** read-only property of the {{domxref("HIDDevice")}} interface returns true if the connection to the {{domxref("HIDDevice")}} is open and ready to transfer data.
## Value
A boolean value, true if the connection is open.
## Examples
The following example retrieves devices with {{domxref("HID.getDevices()")}} and logs the value of `opened` to the console.
```js
document.addEventListener("DOMContentLoaded", async () => {
let devices = await navigator.hid.getDevices();
devices.forEach((device) => {
console.log(`HID: ${device.opened}`);
});
});
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}