GamepadButton: touched property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

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

The touched property of the GamepadButton interface returns a boolean indicating whether a button capable of detecting touch is currently touched (true) or not touched (false).

If the button is not capable of detecting touch but can return an analog value, the property will be true if the value is greater than 0, and false otherwise. If the button is not capable of detecting touch and can only report a digital value, then it should mirror the GamepadButton.pressed property.

Value

A Boolean. True if touched.

Examples

js
let gp = navigator.getGamepads()[0]; // Get the first gamepad object

if (gp.buttons[0].touched) {
  // respond to button being touched
}

Specifications

Specification
Gamepad
# dom-gamepadbutton-touched

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
touched
Chrome – Full support
Chrome 73 (Release date: 2019-03-12)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 55 (Release date: 2017-08-08)
footnote Full support
Opera – Full support
Opera 60 (Release date: 2019-04-09)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 73 (Release date: 2019-03-12)
footnote Full support
Firefox for Android – Full support
Firefox for Android 55 (Release date: 2017-08-08)
footnote Full support
Opera Android – Full support
Opera Android 52 (Release date: 2019-05-17)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 11 (Release date: 2019-12-05)
footnote Full support
WebView Android – Full support
WebView Android 73 (Release date: 2019-03-12)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

See also