Device Orientation

The Device Orientation API allows web applications to access the gyroscope and compass data in order to determine the orientation of the user's device in all the three dimensions, expressed in degrees of divergence from the "natural" northbound lie flat position.

For the detection of the device's movements, see Device Motions.

API glimpse

window.addEventListener('deviceorientation', listener)
An event fired when the significant changes in the device's orientation has occured.
Returns device's current heading (direction) in degrees, counted counterclockwise from the North (0) through West (90), South (180) and East (270).
Returns device's current front/back tilt in degrees, 0 when lying horizontally upward facing, 90 when in vertical position, -90 in vertical upside down, -180 when horizontal upside down.
Returns device's current left/right tilt in degrees, from -90 when turned left to 90 when turned right.