JSPM

evidently-input

1.1.2
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 322
    • Score
      100M100P100Q78102F
    • License MIT

    TypeScript powered for easily handling input in your games.

    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

    Build Status

    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-input

    Documentation

    The simplest way to use this library is as follows:

    1. Create a new instance of MouseInput/KeyboardInput.
    2. Call registerListeners() passing document to it, to register the necessary listeners.
    3. At the end of every frame call update(), it must be done after you've done using the input methods.
    4. 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