# joyp

> Poll the state of the joypads.

Latest version **0.1.1** (published 2026-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install joyp
pnpm add joyp
yarn add joyp
bun add joyp
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2026-03-27 |
| First published | 2019-12-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 367.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | ehgoodenough |
| Keywords | joypad, joypads, gamepad, gamepads, controller, xbox, gamedev, game development, poll, input, browser |

## Links

- npm: https://www.npmjs.com/package/joyp
- Repository: https://github.com/ehgoodenough/joyp
- Homepage: https://github.com/ehgoodenough/joyp#readme
- Issues: https://github.com/ehgoodenough/joyp/issues
- npm.io page: https://npm.io/package/joyp

## Dependencies (1)

- [afloop](https://npm.io/package/afloop.md) ^1.0.2

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2026-03-27
- 0.1.0 — 2019-12-25

## README

# Joyp #

A javascript utility for polling the state of the joypads/gamepads.

### Usage ###

For any given frame of your game loop, you can poll if a button was pressed using `Joyp.wasJustPressed(gamepadIndex, buttonKey)`:

```js
if(Joyp.wasJustPressed(0, "left-trigger")) {
    player.shootGun()
}
```

For the button key, you can use either a [standard button code](https://www.w3.org/TR/gamepad/#remapping) or a human-readable button name, pictured here:

![](diagram.png)

You can also poll the axes of the stick using `Joy.getAxis(gamepadIndex, axisKey)`:

```js
position.x += Joy.getAxis(0, "left-stick-x")
position.y += Joy.getAxis(0, "left-stick-y")
```

### License ###

This project is licensed under the MIT license.

---
_Source: https://npm.io/package/joyp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
