files/en-us/web/api/device_orientation_events/index.md
{{DefaultAPISidebar("Device Orientation Events")}}{{securecontext_header}}
Device orientation events are events that allow you to detect a device's physical orientation, as well as allowing you to detect the device's motion.
Mobile devices commonly have sensors such as gyroscopes, compasses, and accelerometers that can enable applications running on the device to detect the device's orientation and motion.
The device orientation events enable you to write web applications that can change their behavior based on the orientation of the user's device, and that can react when the user moves their device.
Some typical features for which you might want to use the device orientation events include:
in web-based games, to enable the user to control the motion of characters or objects in the game by tilting and moving the device
in mapping applications, to re-orient a map based on the device's position, or to provide turn-by-turn directions that update with the user's movements
for gesture recognition — for example, recognizing a "shake" gesture and using it to perform some action such as clearing an input area when the user shakes the device
Some user agents require explicit permission before providing access to sensor data. In those environments, {{domxref("DeviceMotionEvent.requestPermission_static", "DeviceMotionEvent.requestPermission()")}} and {{domxref("DeviceOrientationEvent.requestPermission_static", "DeviceOrientationEvent.requestPermission()")}} can be used to request this permission from a {{Glossary("transient activation", "transient user activation")}} such as a button click. See Requesting permission for more details.
[!NOTE] This API is widely supported on mobile browsers. While some desktop-only browsers may have limitations due to hardware differences, these constraints are rarely significant given the API's primary usage on sensor-equipped devices.
{{Specifications}}
{{Compat}}