Device Motion API

Access device motion and acceleration data

Motion Data
Real-time device motion values
Acceleration
X: N/AY: N/AZ: N/A
Rotation Rate
α: N/Aβ: N/Aγ: N/A
Device Information
Current device state and settings

Data Ranges

  • • Acceleration: ±10 m/s²
  • • Rotation Rate: ±180°/s
  • • Update Rate: Device dependent
Documentation
Understanding the Device Motion API

What is the Device Motion API?

The Device Motion API provides access to the device's motion and acceleration data. It allows web applications to respond to device movement, including acceleration, rotation, and gravity effects.

Key Features

  • Access device acceleration data
  • Measure rotation rates
  • Include/exclude gravity effects
  • Real-time motion updates
  • Permission-based access control

Browser Support

The Device Motion API is supported in most modern browsers on mobile devices. Some browsers may require HTTPS and explicit user permission.

Best Practices

  • Always check for API support
  • Request permissions when needed
  • Handle null values gracefully
  • Clean up event listeners
  • Consider device compatibility

Example Use Cases

  • Motion-based games
  • Fitness tracking apps
  • Gesture recognition
  • Device movement detection
  • Interactive experiences