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
| Index | Xbox button |
|---|---|
| 0 | A |
| 1 | B |
| 2 | X |
| 3 | Y |
| 4 | Left bumper (LB) |
| 5 | Right bumper (RB) |
| 6 | Left trigger (LT), analog 0 to 1 |
| 7 | Right trigger (RT), analog 0 to 1 |
| 8 | View (Back) |
| 9 | Menu (Start) |
| 10 | Left stick click (L3) |
| 11 | Right stick click (R3) |
| 12 | D-pad Up |
| 13 | D-pad Down |
| 14 | D-pad Left |
| 15 | D-pad Right |
| 16 | Xbox (Guide) button |
Axis indices
| Index | Axis | Range |
|---|---|---|
| 0 | Left stick horizontal | -1 (left) to 1 (right) |
| 1 | Left stick vertical | -1 (up) to 1 (down) |
| 2 | Right stick horizontal | -1 (left) to 1 (right) |
| 3 | Right 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
- Check
gamepad.mapping === 'standard'. Other controllers can report a different layout. - Triggers are buttons with an analog
value, not axes. - The Xbox button often opens the Windows Game Bar and may not reach the page.
- Some controllers add extra buttons, such as Share on Xbox Series controllers, at higher indices, and the number can vary by browser and connection.
- Apply a small deadzone, for example 0.1, to stick values to hide drift.
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.