src/gamecontroller.js
function( eventName, keyCode ) {
			// No keyboard, can't simulate...
			if( typeof window.onkeydown === 'undefined' ) return false;
			var oEvent = document.createEvent('KeyboardEvent');

			// Chromium Hack
			if( navigator.userAgent.toLowerCase().indexOf( 'chrome' ) !== -1 ) {
				Object.defineProperty( oEvent, 'keyCode', {
					get: function() { return this.keyCodeVal; }
				});
				Object.defineProperty( oEvent, 'which', {
					get: function() { return this.keyCodeVal; }
				});
			}

			var initKeyEvent = oEvent.initKeyboardEvent || oEvent.initKeyEvent;
			initKeyEvent.call(oEvent,
				'key' + eventName,
				true,
				true,
				document.defaultView,
				false,
				false,
				false,
				false,
				keyCode,
				keyCode
			);

			oEvent.keyCodeVal = keyCode;
		}
function( eventName, keyCode ) {
			// No keyboard, can't simulate...
			if( typeof window.onkeydown === 'undefined' ) return false;
			var oEvent = document.createEvent('KeyboardEvent');

			// Chromium Hack
			if( navigator.userAgent.toLowerCase().indexOf( 'chrome' ) !== -1 ) {
				Object.defineProperty( oEvent, 'keyCode', {
					get: function() { return this.keyCodeVal; }
				});
				Object.defineProperty( oEvent, 'which', {
					get: function() { return this.keyCodeVal; }
				});
			}

			var initKeyEvent = oEvent.initKeyboardEvent || oEvent.initKeyEvent;
			initKeyEvent.call(oEvent,
				'key' + eventName,
				true,
				true,
				document.defaultView,
				false,
				false,
				false,
				false,
				keyCode,
				keyCode
			);

			oEvent.keyCodeVal = keyCode;
		}
function ( eventName , keyCode ) { // No keyboard, can't simulate... if ( typeof window . onkeydown === 'undefined' ) return false ; var oEvent = document . createEvent ( 'KeyboardEvent' ) ; // Chromium Hack if ( navigator . userAgent . toLowerCase ( ) . indexOf ( 'chrome' ) !== - 1 ) { Object . defineProperty ( oEvent , 'keyCode' , { get : function ( ) { return this . keyCodeVal ; } } ) ; Object . defineProperty ( oEvent , 'which' , { get : function ( ) { return this . keyCodeVal ; } } ) ; } var initKeyEvent = oEvent . initKeyboardEvent || oEvent . initKeyEvent ; initKeyEvent . call ( oEvent , 'key' + eventName , true , true , document . defaultView , false , false , false , false , keyCode , keyCode ) ; oEvent . keyCodeVal = keyCode ; }
Simulates a key press
@param {string} eventName - 'down', 'up'
@param {char} character
Simulates a key press