GamepadButton: pressed property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("Gamepad API")}}{{SecureContext_Header}}
The **GamepadButton.pressed** property of the {{domxref("GamepadButton")}} interface returns a boolean indicating whether the button is currently pressed (true) or unpressed (false).
Value
A boolean value.
Examples
js
let gp = navigator.getGamepads()[0]; // Get the first gamepad object
if (gp.buttons[0].pressed) {
// respond to button being pressed
}Specifications
{{Specifications}}
Browser compatibility
{{Compat}}