Controller Test

Xbox Controller Button Mapping (Gamepad API)

Web developers read gamepad input by number. This chart lists the standard mapping used by the browser Gamepad API for Xbox controllers, which is also what the tester uses.

Button indices

IndexXbox button
0A
1B
2X
3Y
4Left bumper (LB)
5Right bumper (RB)
6Left trigger (LT), analog 0 to 1
7Right trigger (RT), analog 0 to 1
8View (Back)
9Menu (Start)
10Left stick click (L3)
11Right stick click (R3)
12D-pad Up
13D-pad Down
14D-pad Left
15D-pad Right
16Xbox (Guide) button

Axis indices

IndexAxisRange
0Left stick horizontal-1 (left) to 1 (right)
1Left stick vertical-1 (up) to 1 (down)
2Right stick horizontal-1 (left) to 1 (right)
3Right stick vertical-1 (up) to 1 (down)

Reading it in JavaScript

const pad = navigator.getGamepads()[0];
if (pad && pad.mapping === 'standard') {
  const aPressed = pad.buttons[0].pressed;
  const leftX = pad.axes[0];
}

Notes

Ready to check your controller? Open the free Xbox controller tester or run the guided test that walks you through every button.

Frequently asked questions

What are the button numbers for an Xbox controller in the Gamepad API?

A, B, X and Y are 0 to 3, the bumpers are 4 and 5, the triggers 6 and 7, View and Menu 8 and 9, the stick clicks 10 and 11, the D-pad 12 to 15, and the Xbox button 16.

Which axes are the sticks?

Axes 0 and 1 are the left stick, and axes 2 and 3 are the right stick.