inputfusion-js
v1.0.0
Published
Unify input from keyboard, gamepad, touch, and voice into logical actions.
Maintainers
Readme
InputFusion.js
Author: Vatistas Dimitris (vatistasdim)
Unify input detection from keyboard, gamepad, touch, and voice into logical actions for web games and apps.
Features
- Abstract raw inputs into named actions (e.g., jump, moveLeft)
- Bind/unbind controls at runtime
- Supports keyboard, gamepad, touch, and voice
Usage
import InputFusion from 'inputfusion-js';
const fusion = new InputFusion({
actions: {
jump: [{ type: 'keyboard', code: 'Space' }, { type: 'gamepad', code: 'button0' }, { type: 'voice', code: 'jump' }],
moveLeft: [{ type: 'keyboard', code: 'ArrowLeft' }, { type: 'gamepad', code: 'axis0', }]
}
});
fusion.onAction(({ action, value }) => {
console.log(action, value);
});