npm.io
1.5.1 • Published 7 years ago

user-input

Licence
MIT
Version
1.5.1
Deps
4
Size
5 kB
Vulns
0
Weekly
0
Stars
1

user-input

User input tracking for keyboard, mouse, touch, and gamepad inputs.

Usage

NPM

Example

var input   = userInput()
    .withMouse()
    .withKeyboard()
    .withGamepad(0)
    .withTouch()

input.keyboard('A') === 0
// Press A
input.keyboard('A') === 1
    
input.mouse('mouse0') === 0
// Press Left Mouse Button
input.mouse('mouse0') === 1

// Get instances of gamepads, in rendering loops.
input.gamepad()

input.touches        // Current touches
input.changedTouches // Changed touches

// Clear keyboard & mouse values back to zero.
input.clear()

// Set values for testing
input.keyboard('A', 1)
input.mouse('mouse0', 1)
input.mouse('x', 500)

Tests

  • Mocha
    • Test functionality in Node.js

Keywords