← Gamepad button type attribute

v152 · gamepadbutton · attribute · dev trial

GamepadButton.type

Limited availability

  • Chrome · developer trial 152 (desktop, Android) — behind a flag
  • Edge · not separately reported
  • Firefox · no public position recorded
  • Safari · WebKit implementation PR open

No BCD key and no web-features entry for this member (2026-07-29); the parent gamepad web-feature is Baseline widely available. Details on the overview compatibility table.

A read-only attribute that returns a GamepadButtonType enum value — "standard", "non-standard", or "trackpad" — classifying the button's role relative to the Standard Gamepad mapping and its extended-mapping additions. Part of the Gamepad button type attribute feature, in developer trial in Chrome 152.

Developer trial — API surface may move

Behind a flag in Chrome 152: launch with --enable-blink-features=GamepadButtonTypes (runtime feature status experimental, no chrome://flags entry, no origin trial). The defining spec change, w3c/gamepad PR #196, is open — values and semantics may change before merge. Full enable steps on the overview page.

syntax

Verbatim WebIDL from the spec PR:

enum GamepadButtonType {
  "non-standard",
  "standard",
  "trackpad",
};

partial interface GamepadButton {
  readonly attribute GamepadButtonType type;
};

Chromium's IDL is identical in substance, with the runtime gate (gamepad_button.idl, fetched 2026-07-29):

[RuntimeEnabled=GamepadButtonTypes]
readonly attribute GamepadButtonType type;
Source: spec PR preview — GamepadButtonType, GamepadButton (verbatim); gamepad_button.idl (verbatim)

value

A GamepadButtonType string. The enum's three values, with the spec's definitions and Chromium's IDL comments:

GamepadButtonType enum values
ValueSpec definition (PR §14.1.1)Chromium IDL comment
"standard"A button whose type is defined in the Standard Gamepad mapping“A button in the Standard Gamepad layout”
"non-standard"A button that exists but doesn't have a standard name“A button outside the Standard Gamepad layout with no known semantic role”
"trackpad"A trackpad input type“A clickable trackpad surface”

The classification is relative to the extended gamepad button mapping introduced alongside the attribute (PR §14.1): buttons in the 17-entry Standard Gamepad layout are "standard"; extended buttons with a known cross-device semantic role get their own value ("trackpad" is the only such role so far); extended buttons with no standardized role are "non-standard". The explainer is explicit that the value set is a starting point: new classifications require separate spec review and Working Group consensus.

The attribute's getter steps, per the PR preview: “An enumerated GamepadButtonType attribute that classifies the current button's type in relation to an extended mapping.”

Source: spec PR preview §14.1, §14.1.1, type attribute; gamepad_button.idl comments; explainer — classification model, future evolution

inputs

None. type is a read-only attribute: it takes no arguments, has no setter, and is not configurable by the page. The value reflects the user agent's device mapping, not any author-supplied input.

Source: spec PR preview — GamepadButton interface (no setter, no [Throws], readonly)

errors

No error surface exists for this member. The IDL declares no [Throws] annotation and the attribute is read-only, so the getter has no defined exception path; there are no argument-validation, state, or security errors to handle. Reading type on a browser without the feature is a different situation — the property is then absent, not an error: button.type evaluates to undefined and "type" in GamepadButton.prototype is false (see examples).

Source: spec PR preview — IDL; explainer — compatibility (feature detection)

context and exposure

Source: spec PR preview — interface header, §20; gamepad_button.idl

lifecycle

Source: spec PR preview §14.1, §14.2, type attribute

examples

Guard, then classify every button of the first connected gamepad:

if (!("type" in GamepadButton.prototype)) {
  console.log("GamepadButton.type not supported in this browser");
} else {
  const gamepad = navigator.getGamepads()[0];
  gamepad.buttons.forEach((button, index) => {
    console.log(`Button ${index}: type=${button.type}`);
  });
}

Show a touchpad prompt only when the controller actually has one:

const hasTrackpad = gamepad.buttons.some(b => b.type === "trackpad");
if (hasTrackpad) showPrompt("Press the touchpad");
Source: patterns adapted from the explainer — examples, compatibility

browser compatibility

Interim table — no BCD key for type exists (api/GamepadButton.json has only pressed/touched/value, fetched 2026-07-29). Compiled from primary sources:

Interim compatibility for GamepadButton.type (not BCD-derived)
BrowserSupportEvidence
ChromeDeveloper trial 152 (desktop, Android), behind --enable-blink-features=GamepadButtonTypesmilestone=152 listing; flag record
EdgeNot separately reportedChromium-based; no separate position on the record
FirefoxNo public position recordedSpec PR implementation-commitment field for Gecko is an empty bug template (2026-07-29)
Safari / WebKitImplementation in progressWebKit PR #65693 (open)
Source: linked records above, all fetched 2026-07-29

security and privacy

Source: explainer — privacy, security; spec PR preview §14.2, §20

see also