<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/using-gamepads-and-joysticks-in-javascript-lwum52lpt" -->

---
title: Using Gamepads and Joysticks in JavaScript | daily.dev
description: A practical guide to using the Gamepad API in JavaScript. Covers browser support quirks, polling gamepad state via navigator.getGamepads(), the Standard...
canonical: https://daily.dev/posts/using-gamepads-and-joysticks-in-javascript-lwum52lpt
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Using Gamepads and Joysticks in JavaScript | daily.dev
og:description: A practical guide to using the Gamepad API in JavaScript. Covers browser support quirks, polling gamepad state via navigator.getGamepads(), the Standard...
og:url: https://daily.dev/posts/using-gamepads-and-joysticks-in-javascript-lwum52lpt
og:image: https://api.daily.dev/og/posts/lWUM52LPT.png
og:image:alt: Using Gamepads and Joysticks in JavaScript
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Gamepads and Joysticks in JavaScript

**[Beej's Blog](https://daily.dev/sources/beej)** · 15 min read · 0 upvotes · 0 comments

## Summary

A practical guide to using the Gamepad API in JavaScript. Covers browser support quirks, polling gamepad state via navigator.getGamepads(), the Standard Gamepad mapping, detecting connections/disconnections, reading button states and analog axes, implementing dead zones for analog sticks, and clamping joystick values for consistent behavior across different controllers.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <http://beej.us/blog/data/javascript-gamepad/>

## Similar posts on daily.dev

- [The Gamepad API Lies to You: A Practical Guide to Reading Controller Input in JavaScript](https://daily.dev/posts/the-gamepad-api-lies-to-you-a-practical-guide-to-reading-controller-input-in-javascript-92khctuvi) · freeCodeCamp · 1 upvotes · 0 comments
- [CSS Gamepad API Visual Debugging With CSS Layers — Smashing Magazine](https://daily.dev/posts/css-gamepad-api-visual-debugging-with-css-layers-smashing-magazine-v2ttt42ck) · Smashing Magazine · 2 upvotes · 0 comments
- [Why your new gamepad pretends to be an Xbox 360 controller, and why that's actually brilliant](https://daily.dev/posts/why-your-new-gamepad-pretends-to-be-an-xbox-360-controller-and-why-that-s-actually-brilliant-tvu4ssmty) · XDA Developers · 0 upvotes · 0 comments
- [You Can Now Make PS2 Games in JavaScript](https://daily.dev/posts/you-can-now-make-ps2-games-in-javascript-wc5oosia9) · Hacker News · 4 upvotes · 1 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#game-development](https://daily.dev/tags/game-development)

[View this post on daily.dev](https://daily.dev/posts/using-gamepads-and-joysticks-in-javascript-lwum52lpt)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Using Gamepads and Joysticks in JavaScript","url":"https://daily.dev/posts/using-gamepads-and-joysticks-in-javascript-lwum52lpt","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/using-gamepads-and-joysticks-in-javascript-lwum52lpt"},"datePublished":"2026-03-31T12:28:13.136Z","dateModified":"2026-03-31T12:38:30.611Z","description":"A practical guide to using the Gamepad API in JavaScript. Covers browser support quirks, polling gamepad state via navigator.getGamepads(), the Standard...","image":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","thumbnailUrl":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","isAccessibleForFree":true,"articleSection":"Beej's Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Beej's Blog","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/beej"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/using-gamepads-and-joysticks-in-javascript-lwum52lpt","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,game-development","timeRequired":"PT15M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Beej's Blog","item":"https://daily.dev/sources/beej"},{"@type":"ListItem","position":3,"name":"Using Gamepads and Joysticks in JavaScript"}]}
```

