const accelerometer = new Accelerometer({ frequency: 60 });
accelerometer.addEventListener("reading", (e) => {
console.log(`Acceleration along the X-axis ${accelerometer.x}`);
console.log(`Acceleration along the Y-axis ${accelerometer.y}`);
console.log(`Acceleration along the Z-axis ${accelerometer.z}`);
});
accelerometer.start();Accelerometer: y property / notebook
Accelerometer: y property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.