MacBook Pro – Detects Orientation Change

I was working on my new book: Learn HTML5 and JavaScript for iOS, and I noticed something rather strange, my MacBook Pro was providing orientation data to my Chrome browser via the beta and gamma channels. I could move my MacBook and the numbers changed. Wow!

window.ondeviceorientation = function(e) {
    var heading = e.webkitCompassHeading;
    var accuracy = e.webkitCompassAccuracy;
    var alpha = e.alpha;
    var beta = e.beta;
    var gamma = e.gamma;
}