← Gamepad button type attribute
v152 · gamepadbutton · attribute · dev trial
GamepadButton.type
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.
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:
| Value | Spec 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.”
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.
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).
context and exposure
- Exposed in
Windowonly — theGamepadButtoninterface is[Exposed=Window]; the attribute is not available in workers. - Reachable only through a live gamepad — obtain instances via
navigator.getGamepads()[i].buttons[j]; atypevalue is observable only while a gamepad exposing that button is connected. - Permissions Policy — the API is gated by the
gamepadpolicy-controlled feature (default allowlist*); where disabled,getGamepads()and the gamepad connection events are blocked, so noGamepadButtonobjects are reachable (PR preview §20). - Runtime gate in Chromium —
[RuntimeEnabled=GamepadButtonTypes]; without the flag the member is not present on the interface at all.
lifecycle
- Fixed per device mapping — the value is a classification of the physical control's role in the user agent's mapping for that device, not of momentary state. The spec PR defines no mechanism for a button's type to change during a connection, and no event fires for type changes (only the existing
gamepadconnected/gamepaddisconnecteddevice events exist). - Polling model unchanged — like
pressed/touched/value, the attribute is read offGamepadButtonobjects obtained fromnavigator.getGamepads()inside the usual polling loop; unlike those, the classification does not vary frame to frame. - UA mitigation may reshape what's visible — under the base spec's fingerprinting mitigation (§14.2), a user agent MAY clamp the exposed button set to the standard layout, in which case extended buttons (and their
"non-standard"/"trackpad"values) never appear.
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:
| Browser | Support | Evidence |
|---|---|---|
| Chrome | Developer trial 152 (desktop, Android), behind --enable-blink-features=GamepadButtonTypes | milestone=152 listing; flag record |
| Edge | Not separately reported | Chromium-based; no separate position on the record |
| Firefox | No public position recorded | Spec PR implementation-commitment field for Gecko is an empty bug template (2026-07-29) |
| Safari / WebKit | Implementation in progress | WebKit PR #65693 (open) |
security and privacy
- Read-only classification — exposes no device, product, or manufacturer identifiers and nothing not already inferable from button count, indices, and behavior; no new permission is required (explainer security/privacy sections).
- Fingerprinting — the base spec (§14.2) permits the user agent to reduce the exposed capability set to blunt active fingerprinting; the explainer assesses the attribute's added surface as minimal.
- Policy-gated with the rest of the API — inherits the
gamepadPermissions-Policy gate; nothing abouttypebypasses it.
see also
- Gamepad button type attribute — feature overview (this site)
- Chrome Platform Status — Gamepad button type attribute (5075054393163776)
- w3c/gamepad PR #196 preview — GamepadButtonType enum
- MDN — GamepadButton (host interface; does not document
type, 2026-07-29)