forked from mdn/content
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework HID event pages per new structure (mdn#20478)
- Loading branch information
Showing
6 changed files
with
121 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: "HID: connect event" | ||
slug: Web/API/HID/connect_event | ||
page-type: web-api-event | ||
tags: | ||
- API | ||
- Reference | ||
- Event | ||
- HID | ||
- Experimental | ||
browser-compat: api.HID.connect_event | ||
--- | ||
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}} | ||
|
||
The **`connect`** event of the {{domxref("HID")}} interface fires when the user agent connects to a HID device. | ||
|
||
## Syntax | ||
|
||
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property. | ||
|
||
```js | ||
addEventListener('connect', (event) => { }) | ||
|
||
onconnect = (event) => { } | ||
``` | ||
|
||
## Event type | ||
|
||
A {{domxref("HIDConnectionEvent")}}. Inherits from {{domxref("Event")}}. | ||
|
||
{{InheritanceDiagram("HIDConnectionEvent")}} | ||
|
||
## Event properties | ||
|
||
_In addition to the properties listed below, properties from the parent interface, {{domxref("Event")}}, are available._ | ||
|
||
- {{domxref("HIDConnectionEvent.device", "device")}} {{ReadOnlyInline}} | ||
- : The {{domxref("HIDDevice")}} the event is fired for. | ||
|
||
## Examples | ||
|
||
In the following example an event listener is registered to listen for the connection of a device. The name of the device is then printed to the console using {{domxref("HIDDevice.productName")}}. | ||
|
||
```js | ||
navigator.hid.addEventListener('connect', ({device}) => { | ||
console.log(`HID connected: ${device.productName}`); | ||
}); | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: "HID: disconnect event" | ||
slug: Web/API/HID/disconnect_event | ||
page-type: web-api-event | ||
tags: | ||
- API | ||
- Reference | ||
- Event | ||
- HID | ||
- Experimental | ||
browser-compat: api.HID.disconnect_event | ||
--- | ||
{{securecontext_header}}{{APIRef("WebHID API")}}{{SeeCompatTable}} | ||
|
||
The **`disconnect`** event of the {{domxref("HID")}} interface fires when the user agent disconnects a HID device. | ||
|
||
## Syntax | ||
|
||
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property. | ||
|
||
```js | ||
addEventListener('disconnect', (event) => { }) | ||
|
||
ondisconnect = (event) => { } | ||
``` | ||
|
||
## Event type | ||
|
||
A {{domxref("HIDConnectionEvent")}}. Inherits from {{domxref("Event")}}. | ||
|
||
{{InheritanceDiagram("HIDConnectionEvent")}} | ||
|
||
## Event properties | ||
|
||
_In addition to the properties listed below, properties from the parent interface, {{domxref("Event")}}, are available._ | ||
|
||
- {{domxref("HIDConnectionEvent.device", "device")}} {{ReadOnlyInline}} | ||
- : The {{domxref("HIDDevice")}} the event is fired for. | ||
|
||
## Examples | ||
|
||
In the following example an event listener is registered to listen for the disconnection of a device. The name of the device is then printed to the console using {{domxref("HIDDevice.productName")}}. | ||
|
||
```js | ||
navigator.hid.addEventListener('connect', ({device}) => { | ||
console.log(`HID connected: ${device.productName}`); | ||
}); | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.