index.js
function Keyboard(keyMap) {
	/**
	 * The current key states.
	 * @member {object}
	 * @private
	 */
	this.keys = {};

	var self = this;
	for (var kc in keyMap) {
		if (keyMap.hasOwnProperty(kc)) {
			this.keys[keyMap[kc]] = 0;
		}
	}
	window.addEventListener("keydown", function(event) {
		if (keyMap.hasOwnProperty(event.keyCode)) {
			if (self.keys[keyMap[event.keyCode]] === 0) {
				self.keys[keyMap[event.keyCode]] = 2;
			}
			return false;
		}
	});
	window.addEventListener("keyup", function(event) {
		if (keyMap.hasOwnProperty(event.keyCode)) {
			self.keys[keyMap[event.keyCode]] = 0;
			return false;
		}
	});
}
function Keyboard(keyMap) {
	/**
	 * The current key states.
	 * @member {object}
	 * @private
	 */
	this.keys = {};

	var self = this;
	for (var kc in keyMap) {
		if (keyMap.hasOwnProperty(kc)) {
			this.keys[keyMap[kc]] = 0;
		}
	}
	window.addEventListener("keydown", function(event) {
		if (keyMap.hasOwnProperty(event.keyCode)) {
			if (self.keys[keyMap[event.keyCode]] === 0) {
				self.keys[keyMap[event.keyCode]] = 2;
			}
			return false;
		}
	});
	window.addEventListener("keyup", function(event) {
		if (keyMap.hasOwnProperty(event.keyCode)) {
			self.keys[keyMap[event.keyCode]] = 0;
			return false;
		}
	});
}
function Keyboard ( keyMap ) { /**
	 * The current key states.
	 * @member {object}
	 * @private
	 */ this . keys = { } ; var self = this ; for ( var kc in keyMap ) { if ( keyMap . hasOwnProperty ( kc ) ) { this . keys [ keyMap [ kc ] ] = 0 ; } } window . addEventListener ( "keydown" , function ( event ) { if ( keyMap . hasOwnProperty ( event . keyCode ) ) { if ( self . keys [ keyMap [ event . keyCode ] ] === 0 ) { self . keys [ keyMap [ event . keyCode ] ] = 2 ; } return false ; } } ) ; window . addEventListener ( "keyup" , function ( event ) { if ( keyMap . hasOwnProperty ( event . keyCode ) ) { self . keys [ keyMap [ event . keyCode ] ] = 0 ; return false ; } } ) ; }
Keyboard input handling.
@constructor
@param {module:KeyMap} keymap A map of keycodes to descriptive key names.
Keyboard input handling .