Class: Joy

Joy()

Manages gamepad input via the browser's Gamepad API.

Constructor

new Joy()

Source:

Classes

Joy

Methods

joyDown(button, padIndexopt) → {boolean}

Checks if a specific gamepad button is currently held down.
Parameters:
Name Type Attributes Default Description
button number The index of the button to check.
padIndex number <optional>
0 The index of the gamepad.
Source:
Returns:
True if the button is pressed.
Type
boolean

joyType(padIndexopt) → {string}

Returns the identifier string for a connected gamepad.
Parameters:
Name Type Attributes Default Description
padIndex number <optional>
0 The index of the gamepad.
Source:
Returns:
The gamepad's ID string, or "Not connected".
Type
string

joyX(padIndexopt) → {number}

Returns the position of the primary horizontal axis (usually the left stick). Includes a deadzone to prevent drift.
Parameters:
Name Type Attributes Default Description
padIndex number <optional>
0 The index of the gamepad.
Source:
Returns:
A value between -1.0 (left) and 1.0 (right).
Type
number

joyY(padIndexopt) → {number}

Returns the position of the primary vertical axis (usually the left stick). Includes a deadzone to prevent drift.
Parameters:
Name Type Attributes Default Description
padIndex number <optional>
0 The index of the gamepad.
Source:
Returns:
A value between -1.0 (up) and 1.0 (down).
Type
number