GamepadEvent: GamepadEvent() constructor

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The GamepadEvent() constructor creates a new GamepadEvent object.

Syntax

js
new GamepadEvent(type, options)

Parameters

type

A string with the name of the event. It is case-sensitive and browsers set it to gamepadconnected or gamepaddisconnected.

options

An object that, in addition of the properties defined in Event(), can have the following properties:

gamepad

A Gamepad object describing the gamepad associated with the event.

Return value

A new GamepadEvent object.

Specifications

Specification
Gamepad
# dom-gamepadevent-constructor

Browser compatibility

BCD tables only load in the browser