Package Exports
- evidently-input
- evidently-input/dist/KeyboardInput
- evidently-input/dist/MouseInput
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (evidently-input) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Evidently Input
A set of classes to make it easier and simpler to work with input (Mouse/Keyboard) in your games.
Getting Started
The full documentation can be found here.
Installing
Add it to your project via:
npm i --save evidently-inputDocumentation
The simplest way to use this library is as follows:
- Create a new instance of
MouseInput/KeyboardInput. - Call
registerListeners()passingdocumentto it, to register the necessary listeners. - At the end of every frame call
update(), it must be done after you've done using the input methods. - Where needed call the appropriate methods (eg.
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);License
This project is licensed under the MIT License - see the LICENSE.md file for details