• Skip to main content
  • Skip to search
  • Skip to select language
MDN Logo
    • Technologies Overview
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs
    • Browser Extensions
    • MathML
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
    • Send Feedback
    • Contribute to MDN
    • Report a content issue 🌐
    • Report a platform issue 🌐
  1. Web technology for developers
  2. Web APIs
  3. GamepadButton
  4. GamepadButton.pressed
  • Change language

Table of contents

  • Examples
  • Value
  • Specifications
  • Browser compatibility
  • See also

GamepadButton.pressed

The GamepadButton.pressed property of the GamepadButton interface returns a boolean indicating whether the button is currently pressed (true) or unpressed (false).

Examples

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

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

Value

A boolean value.

Specifications

Specification
Gamepad
# dom-gamepadbutton-pressed

Browser compatibility

See also

  • Using the Gamepad API

Found a problem with this page?

  • Edit on GitHub
  • Source on GitHub
  • Report a problem with this content on GitHub
  • Want to fix the problem yourself? See our Contribution guide.

Last modified: Mar 30, 2022, by MDN contributors

Change your language

Related Topics

  1. Gamepad API
  2. GamepadButton
  3. Properties
    1. pressed
    2. touched
    3. value
  4. Related pages for Gamepad API
    1. Gamepad
    2. GamepadEvent
    3. Navigator.getGamepads()
    4. Window.ongamepadconnected
    5. Window.ongamepaddisconnected
MDN Logo
  • Web Technologies
  • Learn Web Development
  • About MDN
  • Feedback
  • About
  • MDN Web Docs Store
  • Contact Us
  • Firefox

MDN

  • MDN on Twitter
  • MDN on Github

Mozilla

  • Mozilla on Twitter
  • Mozilla on Instagram

© 2005-2025 Mozilla and individual contributors. Content is available under these licenses.

  • Terms
  • Privacy
  • Cookies