window.addEventListener("gamepadconnected", (e) => {
if (!e.gamepad.displayId) {
console.log("Gamepad connected");
} else {
console.log(
`Gamepad connected, associated with VR display ${e.gamepad.displayId}`,
);
}
});Gamepad: displayId property / notebook
Gamepad: displayId property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.