Vibration API

suggest change

Modern mobile devices can vibrate. The Vibration API allows Web apps the trigger vibration of the device (if its supported by the hardware).

Support by browsers and operating systems might be limited.

Single vibration

Vibrate the device for 100 ms:

const didVibrate = window.navigator.vibrate(100);

or

const didVibrate = window.navigator.vibrate([100]);

Check if vibration is supported

Check if browser supports vibrations

if ('vibrate' in window.navigator) {
    // browser has support for vibrations
} else {
    // no support
}

Vibration patterns

An array of values describes periods of time in which the device is vibrating and not vibrating.

window.navigator.vibrate([200, 100, 200]);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Vibration API:

Table Of Contents
11 Arrays
12 Objects
14 Classes
16 Map
17 Set
24 Loops
27 Date
29 Scope
30 AJAX
35 Cookies
41 JSON
44 Fetch
45 Modules
46 Screen
64 Console
68 Symbols
73 Modals
76 Events
86 Proxy
89 WeakMap
90 WeakSet
100 Vibration API
102 Tilde