JavaScripture
Contribute via GitHub Feedback

Gamepad : Object

Represents a gamepad/controller. Connected gamepads are available through the navigator.getGamepads() method.

Instance Properties

axes : Array<Number>  

The joystick positions. May also contain the direction pad (+) pressed direction.

Example:

Run

Results:

 

buttons : Array<GamepadButton>  

The state of the buttons on the controller.

Example:

Run

Results:

 

connected : Boolean  

true when the gamepad is connected.

Example:

Run

Results:

 

id : String  

An id for the controller.

Example:

Run

Results:

 

index : Number  

Example:

Run

Results:

 

mapping : String  

Either '' or 'standard'. If 'standard', the buttons/axes will follow the layout as seen at https://w3c.github.io/gamepad/#fig-visual-representation-of-a-standard-gamepad-layout.

Example:

Run

Results:

 

timestamp : Number  

The last time there was an update from the gamepad. In milliseconds.

Example:

Run

Results: