public/js-roguelike-skeleton/src/input.js
function Input(onKeyAction, bindings) {
        this.bindings = {};
        if (onKeyAction !== void 0) {
            this.onKeyAction = onKeyAction;
        }
        if (bindings !== void 0) {
            this.addBindings(bindings);
        }
        this.startListening();
    }
function Input(onKeyAction, bindings) {
        this.bindings = {};
        if (onKeyAction !== void 0) {
            this.onKeyAction = onKeyAction;
        }
        if (bindings !== void 0) {
            this.addBindings(bindings);
        }
        this.startListening();
    }
function Input ( onKeyAction , bindings ) { this . bindings = { } ; if ( onKeyAction !== void 0 ) { this . onKeyAction = onKeyAction ; } if ( bindings !== void 0 ) { this . addBindings ( bindings ) ; } this . startListening ( ) ; }
Helper for binding user key input to actions.
@class Input
@constructor
@param {Function} onKeyAction - Function called when a key bound to an action is pressed (function(action){}).
@param {Object} bindings - An object of key val pairs mapping an action to an array of keys that trigger it. Input.Keys is used to convert input key string names to key codes.
@param bindings.action1 {Array} Input keys mapped to action1. ['A', 'B', ...]
@param bindings.action2 {Array} Input keys mapped to action2. ['X', 'Y', ...]
@param bindings....
@example
bindings param example:
{
up: ['UP_ARROW'],
down: ['DOWN_ARROW'],
left: ['LEFT_ARROW'],
right: ['RIGHT_ARROW'],
}
Helper for binding user key input to actions .