Limited availability
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The reading
event is fired when a new reading is available on a sensor.
The Sensor
interface is a base class, onreading
and the reading
event may only be used on one of the derived classes.
Use the event name in methods like addEventListener()
, or set an event handler property.
addEventListener("reading", (event) => { })
onreading = (event) => { }
Event type
A generic Event
with no added properties.
This example adds an event listener to read acceleration values of an Accelerometer
. It reads sixty times a second.
const acl = new Accelerometer({ frequency: 60 });
acl.addEventListener("reading", () => {
console.log(`Acceleration along the X-axis ${acl.x}`);
console.log(`Acceleration along the Y-axis ${acl.y}`);
console.log(`Acceleration along the Z-axis ${acl.z}`);
});
acl.start();
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4