Vibration API

Causes the device to vibrate.

Uses

  • Haptic user feedback for successes and errors
  • User feedback for general page interactions
  • Feeling sound
  • Haptic Morse code

Example

if ('vibrate' in navigator) {
   // Vibrate once for one second
   navigator.vibrate(1000);
   // Vibrate in sequence of 'on' then 'off' as specified in ms
   navigator.vibrate([1000,500,2000,500,2000]);
} else {
   // Not supported
   console.warn('Vibrate not supported')
}