updated the description of gamepad documentation#43760
Merged
chrisdavidmills merged 3 commits intomdn:mainfrom Apr 13, 2026
Merged
updated the description of gamepad documentation#43760chrisdavidmills merged 3 commits intomdn:mainfrom
chrisdavidmills merged 3 commits intomdn:mainfrom
Conversation
Contributor
|
Preview URLs (1 page) (comment last updated: 2026-04-13 08:31:57) |
chrisdavidmills
requested changes
Apr 13, 2026
Contributor
chrisdavidmills
left a comment
There was a problem hiding this comment.
Hi @narasimhan-lakshmi! I have a few comments for you to consider, but this is looking mostly good.
|
|
||
| > [!NOTE] | ||
| > The Gamepad object is available on the {{ domxref("Window/gamepadconnected_event", "gamepadconnected") }} event rather than the {{ domxref("Window") }} object itself, for security reasons. Once we have a reference to it, we can query its properties for information about the current state of the gamepad. Behind the scenes, this object will be updated every time the gamepad's state changes. | ||
| > The Gamepad object is available on the {{ domxref("Window/gamepadconnected_event", "gamepadconnected") }} event rather than the {{ domxref("Window") }} object itself, for security reasons. You can also access gamepads through {{domxref("Navigator.getGamepads()")}}. In practice, poll {{domxref("Navigator.getGamepads()")}} and read the current object for a known `index` each frame, instead of relying on a long-lived reference from an earlier event. |
Contributor
There was a problem hiding this comment.
Suggested change
| > The Gamepad object is available on the {{ domxref("Window/gamepadconnected_event", "gamepadconnected") }} event rather than the {{ domxref("Window") }} object itself, for security reasons. You can also access gamepads through {{domxref("Navigator.getGamepads()")}}. In practice, poll {{domxref("Navigator.getGamepads()")}} and read the current object for a known `index` each frame, instead of relying on a long-lived reference from an earlier event. | |
| > The Gamepad object is available on the {{ domxref("Window/gamepadconnected_event", "gamepadconnected") }} event rather than the {{ domxref("Window") }} object itself, for security reasons. You can also access gamepads through {{domxref("Navigator.getGamepads()")}}. In practice, you should poll {{domxref("Navigator.getGamepads()")}} and read the current object for a known `index` each frame, rather than relying on a long-lived reference from an earlier event. |
Contributor
Author
|
Hello @chrisdavidmills, have made the suggested changes. Kindly review |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
chrisdavidmills
approved these changes
Apr 13, 2026
Contributor
chrisdavidmills
left a comment
There was a problem hiding this comment.
Looking good. Thanks for the fix, @narasimhan-lakshmi!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Removed wording that implied a Gamepad object from gamepadconnected can be safely held and continuously queried.
Updated guidance to use gamepad index as the stable identifier and call navigator.getGamepads() each frame for fresh state.
Adjusted the sample code to track connected controllers by index/state instead of storing the original event Gamepad object.
Motivation
Makes the reader to understand better.
Additional details
Related issues and pull requests
Fixes #14874