Example: Vibration

This is an experimental feature. Not all gamepad/joysticks will support vibration on a browser. Even the ones that can vibrate, may not be able to vibrate on a browser because this is a not widely supported feature.

Connect your gamepad/joystick, and click on the button to trigger the vibration.

How it works

Vibration of the gamepad can be triggered using the .vibrate() method of the gamepad object. That method takes two parameters:

The .vibrate() method can be called without parameters. In that case, the intensity will be 0.75 by default, and the duration will be 500 milliseconds (half a second.)

gameControl.on('connect', function(gamepad) {

  if (gamepad.vibration) {
    gamepad.vibrate(0.5, 1000);
  }
  
});

If several vibrations are called, they won't be chained. Instead the last one will overwrite the existing one.