Device Motion and Device Orientation Value Shower

because why the hell not

by Augustus Yuan

HTML

<div class="device-motion">
<h1>Device Motion</h1>
<pre id="device-motion-values"></pre>
</div>

<div class="device-orientation">
<h1>Device Orientation</h1>
<pre id="device-orientation-values"></pre>
</div>

JavaScript

window.addEventListener("deviceorientation", function(event) {
    document.getElementById('device-orientation-values').innerHTML = JSON.stringify(event);
  }, true);
  
window.addEventListener("devicemotion", function(event) {
    document.getElementById('device-motion-values').innerHTML = JSON.stringify(event);
}, true);