A set of classes to make it easier and simpler to work with input (Mouse/Keyboard) in your games.
The full documentation can be found here.
Add it to your project via:
npm i --save evidently-input
The simplest way to use this library is as follows:
MouseInput
/KeyboardInput
.registerListeners()
passing document
to it, to register the necessary listeners.update()
, it must be done after you've done using the input methods.keyboardInput.isKeyDown()-
).An example code:
const mouseInput = new MouseInput();
const keyboardInput = new KeyboardInput();
// Registers necessary event listeners on the document
mouseInput.registerListeners(document);
keyboardInput.registerListeners(document);
setInterval(() => {
console.log(mouseInput.localX, mouseInput.localY, keyboardInput.isKeyDown(' '));
// This has to run every frame after you've done processing it, so ideally at the end.
mouseInput.update();
keyboardInput.update();
}, 1000/60);
This project is licensed under the MIT License - see the LICENSE.md file for details
Generated using TypeDoc