# input.js

> Update input states every frame

Latest version **1.3.0** (published 2018-01-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install input.js
pnpm add input.js
yarn add input.js
bun add input.js
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2018-01-20 |
| First published | 2017-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | jwu |
| Maintainers | johnnywu |
| Keywords | input, mouse, keyboard, touch |

## Links

- npm: https://www.npmjs.com/package/input.js
- Repository: https://github.com/gamedev-js/input.js
- Homepage: https://github.com/gamedev-js/input.js/issues
- Issues: https://github.com/gamedev-js/input.js/issues
- npm.io page: https://npm.io/package/input.js

## Dependencies (2)

- [memop](https://npm.io/package/memop.md) ^1.6.0
- [electron-node-tap](https://npm.io/package/electron-node-tap.md) ^1.1.4

## Recent versions

- 1.3.0 (latest) — 2018-01-20
- 1.2.3 — 2017-12-04
- 1.2.2 — 2017-11-23
- 1.2.1 — 2017-11-13
- 1.2.0 — 2017-10-30
- 1.1.7 — 2017-10-19
- 1.1.6 — 2017-07-12
- 1.1.5 — 2017-07-06
- 1.1.4 — 2017-06-30
- 1.1.3 — 2017-06-30
- 1.1.2 — 2017-03-22
- 1.1.1 — 2017-03-15
- 1.1.0 — 2017-03-14
- 1.0.4 — 2017-03-13
- 1.0.3 — 2017-03-13
- … 2 more at https://npm.io/package/input.js/versions

## README

## Input States

Update input states every frame.

## Install

```bash
npm install input.js
```

## Usage

```javascript
let input = new Input();

function animate() {
  if (input.keydown('w')) {
    console.log('key w down');
  }

  input.reset();
  requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
```

## Documentation

- [Mouse](docs/mouse.md)
- [Keyboard](docs/keyboard.md)
- [Touches](docs/touches.md)

## TODO

 - options
   - lock-filter (a filter function to decide if enter the lock state)
 - api
   - installTouches()
 - extensions
   - input.mouseclick(name, downupSpan, dragDistance)
   - input.mouseclicks(name, clickCount, downupSpan, clickSpan, dragDistance)
   - input.keyclick(name, downupSpan)
   - input.keyclicks(name, clickCount, downupSpan, clickSpan)

## License

MIT © 2017 Johnny Wu

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