nx.js
Enumerations

Button

Mapping of the button indices on a Gamepad to the corresponding name of the button on the controller.

The order is not the standard Web Gamepad API order — it follows the order of buttons as reported by the Switch's HID service. Always use this enum (or named members) to look up buttons in Gamepad.buttons[] rather than hard-coding indices.

Example

import { Button } from '@nx.js/constants';

const pad = navigator.getGamepads()[0];
if (pad.buttons[Button.A].pressed) {
  console.log('Button A is pressed');
}

Enumeration Members

Enumeration MemberValueDescription
A1A button (right-side face button — right position).
B0B button (right-side face button on Pro/Joy-Con grip — down position).
Down13D-Pad Down.
L4L shoulder button.
Left14D-Pad Left.
Minus8Minus (–) button.
Plus9Plus (+) button.
R5R shoulder button.
Right15D-Pad Right.
StickL10Click of the Left Stick.
StickR11Click of the Right Stick.
Up12D-Pad Up.
X3X button (left-side face button — up position).
Y2Y button (left-side face button — left position).
ZL6ZL trigger.
ZR7ZR trigger.

On this page