Overview

The Vibration API provides a simple way to trigger the vibration hardware on mobile devices. It can be used for single pulses or complex patterns of vibration and silence.

Usage

navigator.vibrate(200) (vibrate for 200ms) or navigator.vibrate([100, 50, 100]) (vibrate, pause, vibrate). It requires a user gesture to prevent abusive behavior.

Use Cases

  • Gaming: Providing feedback for in-game actions (e.g., taking damage).
  • Form Validation: A short 'buzz' to indicate an error in an input field.
  • Notifications: Enhancing web-based alerts with physical feedback.

Related Terms