Back to Content

Gamepad: connected property

files/en-us/web/api/gamepad/connected/index.md

latest543 B
Original Source

{{APIRef("Gamepad API")}}

The Gamepad.connected property of the {{domxref("Gamepad") }} interface returns a boolean indicating whether the gamepad is still connected to the system.

If the gamepad is connected, the value is true; if not, it is false.

Value

A boolean.

Examples

js
const gp = navigator.getGamepads()[0];
console.log(gp.connected);

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

Using the Gamepad API