Update input states every frame.
npm install input.js
let input = new Input();
function animate() {
if (input.keydown('w')) {
console.log('key w down');
}
input.reset();
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
- 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)
MIT © 2017 Johnny Wu