GamepadHapticActuator: playEffect() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The playEffect() method of the GamepadHapticActuator interface causes the hardware to play a specific vibration effect.

Syntax

js
playEffect(type, params)

Parameters

type

A string representing the desired effect. Possible values are "dual-rumble" and "trigger-rumble", and their effects can vary depending on the hardware type. See GamepadHapticActuator.effects for further details of the effect types.

params

An object to describe a desired haptic effect.

Expected values are:

duration Optional

The duration of the effect in milliseconds. Defaults to 0.

startDelay Optional

The delay in milliseconds before the effect is started. Defaults to 0.

strongMagnitude Optional

The rumble intensity of the low-frequency (strong) rumble motors, normalized to the range between 0.0 and 1.0. Defaults to 0.0.

weakMagnitude Optional

The rumble intensity of the high-frequency (weak) rumble motors, normalized to the range between 0.0 and 1.0. Defaults to 0.0.

leftTrigger (relevant to "trigger-rumble" effects only) Optional

The rumble intensity of the bottom-left front trigger, normalized to the range between 0.0 and 1.0. Defaults to 0.0.

rightTrigger (relevant to "trigger-rumble" effects only) Optional

The rumble intensity of the bottom-right front trigger, normalized to the range between 0.0 and 1.0. Defaults to 0.0.

Note: A new call to playEffect() overrides a previous ongoing call.

Return value

A promise that resolves with "complete" when the effect successfully completes, or "preempted" if the current effect is stopped or replaced by another effect.

The promise may reject with the following exception types:

InvalidStateError DOMException

The current document is not active or hidden.

NotSupportedError DOMException

The requested type is not supported by the current gamepad's actuator.

TypeError DOMException

The requested type is not a valid effect type.

Examples

js
const gamepad = navigator.getGamepads()[0];

gamepad.vibrationActuator
  .playEffect("dual-rumble", {
    startDelay: 0,
    duration: 200,
    weakMagnitude: 1.0,
    strongMagnitude: 1.0,
  })
  .then((result) => console.log(result));
// Should log "complete" if effect successfully runs

Specifications

Specification
Gamepad
# dom-gamepadhapticactuator-playeffect

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
playEffect
Chrome – Full support
Chrome 68 (Release date: 2018-07-24)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 55 (Release date: 2018-08-16)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 68 (Release date: 2018-07-24)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 48 (Release date: 2018-11-08)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 68 (Release date: 2018-07-24)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
params.leftTrigger parameter
Experimental
Chrome – Full support
Chrome 126 (Release date: 2024-06-11)
footnote Full support
Edge – Full support
Edge 126 (Release date: 2024-06-13)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 112 (Release date: 2024-07-11)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 126 (Release date: 2024-06-11)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 83 (Release date: 2024-06-25)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 28 (Release date: 2025-04-02)
footnote Full support
WebView Android – Full support
WebView Android 126 (Release date: 2024-06-11)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
params.rightTrigger parameter
Experimental
Chrome – Full support
Chrome 126 (Release date: 2024-06-11)
footnote Full support
Edge – Full support
Edge 126 (Release date: 2024-06-13)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 112 (Release date: 2024-07-11)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 126 (Release date: 2024-06-11)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 83 (Release date: 2024-06-25)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 28 (Release date: 2025-04-02)
footnote Full support
WebView Android – Full support
WebView Android 126 (Release date: 2024-06-11)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
trigger-rumble effect type
Experimental
Chrome – Full support
Chrome 126 (Release date: 2024-06-11)
footnote Full support
Edge – Full support
Edge 126 (Release date: 2024-06-13)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 112 (Release date: 2024-07-11)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 126 (Release date: 2024-06-11)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 83 (Release date: 2024-06-25)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 28 (Release date: 2025-04-02)
footnote Full support
WebView Android – Full support
WebView Android 126 (Release date: 2024-06-11)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

See also