GamepadHapticActuator

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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.

Properties

GamepadHapticActuator.type Read only

Returns an enum representing the type of the haptic hardware.

Methods

GamepadHapticActuator.pulse() Read only

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

GamepadHapticActuator.playEffect() Read only

Makes the hardware play a specific vibration pattern.

Examples

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

Specification
Gamepad Extensions
# gamepadhapticactuator-interface

Browser compatibility

BCD tables only load in the browser

See also