GamepadButton.touched

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.

Example

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

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

Specifications

No specification found

No specification data found for api.GamepadButton.touched.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
touched
73
15
55
No
60
10.1
No
73
55
52
10.3
11.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GamepadButton/touched