W3cubDocs

/Web APIs

GamepadHapticActuator

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The GamepadHapticActuator interface of the Gamepad API represents hardware in the controller designed to provide haptic feedback to the user (if available), most commonly vibration hardware.

This interface is accessible through the Gamepad.hapticActuators property.

Instance properties

GamepadHapticActuator.type Read only

Returns an enum representing the type of the haptic hardware.

Instance methods

GamepadHapticActuator.pulse() Read only

Makes the hardware pulse at a certain intensity for a specified duration.

GamepadHapticActuator.playEffect() Read only Non-standard

Makes the hardware play a specific vibration pattern.

Examples

js

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

gamepad.hapticActuators[0].pulse(1.0, 200);

gamepad.vibrationActuator.playEffect("dual-rumble", {
  startDelay: 0,
  duration: 200,
  weakMagnitude: 1.0,
  strongMagnitude: 1.0,
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
GamepadHapticActuator 68 15 55 No 55 16.4 68 68 55 48 16.4 10.0
canPlayEffectType No No No No No 16.4 No No No No 16.4 No
playEffect 68 15 No No 55 16.4 68 68 No 48 16.4 10.0
pulse No 15–79 55 No No No No No 55 No No No
reset 68 15 No No 55 16.4 68 68 No 48 16.4 10.0
secure_context_required 86 86 91 No 72 No No 86 91 No No No
type 68 15 55 No 55 16.4 68 68 55 48 16.4 10.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GamepadHapticActuator