Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt api.HIDDevice.oninputreport to new events structure #13524

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7963,6 +7963,7 @@
/en-US/docs/Web/API/GlobalFetch/GlobalFetch.fetch() /en-US/docs/Web/API/fetch
/en-US/docs/Web/API/GlobalFetch/fetch /en-US/docs/Web/API/fetch
/en-US/docs/Web/API/Guide/Events/Creating_and_triggering_events /en-US/docs/Web/Events/Creating_and_triggering_events
/en-US/docs/Web/API/HIDDevice/oninputreport /en-US/docs/Web/API/HIDDevice/inputreport_event
/en-US/docs/Web/API/HTMLAnchorElement.rel /en-US/docs/Web/API/HTMLAnchorElement/rel
/en-US/docs/Web/API/HTMLAnchorElement.relList /en-US/docs/Web/API/HTMLAnchorElement/relList
/en-US/docs/Web/API/HTMLAnchorElement/referrer /en-US/docs/Web/API/HTMLAnchorElement/referrerPolicy
Expand Down
6 changes: 3 additions & 3 deletions files/en-us/web/api/hiddevice/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ This interface also inherits properties from {{domxref("EventTarget")}}.
- {{domxref("HIDDevice.collections")}}{{ReadOnlyInline}}
- : Returns an array of report formats for the HID device.

### Event handlers
### Events

- {{domxref("HIDDevice.oninputreport")}}
- : An event handler that fires when a report is sent from the device.
- {{domxref("HIDDevice.inputreport_event", "inputreport")}}
- : Fires when a report is sent from the device.

## Methods

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
---
title: HIDDevice.oninputreport
slug: Web/API/HIDDevice/oninputreport
title: 'HIDDevice: inputreport event'
slug: Web/API/HIDDevice/inputreport_event
tags:
- API
- Property
- Reference
- oninputreport
- HIDDevice
browser-compat: api.HIDDevice.oninputreport
browser-compat: api.HIDDevice.inputreport_event
---
{{securecontext_header}}{{DefaultAPISidebar("WebHID API")}}

The **`oninputreport`** event handler of the {{domxref("HIDDevice")}} interface processes inputreport events.

The event fires when a new report is received from the HID device.
The **`inputreport`** event of the {{domxref("HIDDevice")}} interface fires when a new report is received from the HID device.

## Syntax

Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.

```js
HIDDevice.oninputreport = function;
HIDDevice.addEventListener('inputreport', function);
addEventListener('inputreport', event => { });

oninputreport = event => { };
```

## Event type

An {{domxref("HIDInputReportEvent")}}. Inherits from {{domxref("Event")}}.

{{InheritanceDiagram("HIDInputReportEvent")}}

## Event properties

{{page("/en-US/docs/Web/API/HIDInputReportEvent", "Properties")}}

## Example

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. You can see more examples, and live demos in the article [Connecting to uncommon HID devices](https://web.dev/hid/).
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/hidinputreportevent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ browser-compat: api.HIDInputReportEvent
---
{{securecontext_header}}{{DefaultAPISidebar("WebHID API")}}

The **`HIDInputReportEvent`** interface of the {{domxref('WebHID API')}} is passed to {{domxref("HIDDevice.oninputreport")}} when an input report is received from any associated HID device.
The **`HIDInputReportEvent`** interface of the {{domxref('WebHID API')}} is passed to {{domxref("HIDDevice.inputreport_event")}} when an input report is received from any associated HID device.

{{InheritanceDiagram}}

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/webhid_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ A Human Interface Device (HID) is a type of device that takes input from or prov
<!---->

- {{domxref("HIDInputReportEvent")}}
- : Passed to {{domxref("HIDDevice.oninputreport")}} when an input report is received from any associated HID device.
- : Passed to {{domxref("HIDDevice.inputreport_event")}} when an input report is received from any associated HID device.

<!---->

Expand Down