Touch Develop retirement postponed until June 22, 2019. Sign-in and access to cloud assets to be removed on May 23, 2018.Learn More..


A Gamepad instance contains the state of the gamepad axes and buttons at a given time.

looking for the gamepad library?

The gamepad library provide a virtualized access to keyboard, mouse, touch and physical gamepads.
var p2 :=  gamepad → current
The rest of this document treats with the API to handle physical gamepads connected to the browser.

reading all gamepads

The state of all gamepads can be retreived through this call.
var gamepads := senses → gamepads
If a gamepad is connected and supported by the browser, it will be available in the collection. Make sure to always check if a gamepad is available.
if gamepads → count > 0 then
At least 1 gamepad...
else ... end if
You need to press a button once on the gamepad to 'enable' it.

getting "the" gamepad

Assuming you have a single player scenario, you can use the senses→first gamepad action.
var gamepad := senses → first gamepad


The gamepad exposes 16 buttons. The button layout is explained in the W3C specification. The button names will appear in the editor.
  • you can test if a button is pressed
if gamepad → is button pressed("left trigger") then
else ... end if
  • you can get the normalized value of a button. If the button is analog, it might return intermediate values between 0` and 1``.
var x := gamepad → button value("up")


The gamepad exposes 2 axes for the left stick and right stick. Each axes exposes an x and y value in [-1, 1].
var p := gamepad → axes("left stick")

virtual gamepad

The gamepad library can help you provide multiple input types to your app; not just the gamepad or touch or keyboard but all of them.