index.js
function createKeyboardEvent(type, options) {
  options = clean(type, options);
  var e = document.createEvent('KeyboardEvent');
  (e.initKeyEvent || e.initKeyboardEvent).call(
    e,
    type,
    options.bubbles,
    options.cancelable,
    options.view,
    options.ctrl,
    options.alt,
    options.shift,
    options.meta,
    options.key,
    options.key
  );

  // http://stackoverflow.com/a/10520017
  if (e.keyCode !== options.key) {
    Object.defineProperty(e, 'keyCode', {
      get: function() { return options.key; }
    });
    Object.defineProperty(e, 'charCode', {
      get: function() { return options.key; }
    });
    Object.defineProperty(e, 'which', {
      get: function() { return options.key; }
    });
    Object.defineProperty(e, 'shiftKey', {
      get: function() { return options.shift; }
    });
  }

  return e;
}
function createKeyboardEvent(type, options) {
  options = clean(type, options);
  var e = document.createEvent('KeyboardEvent');
  (e.initKeyEvent || e.initKeyboardEvent).call(
    e,
    type,
    options.bubbles,
    options.cancelable,
    options.view,
    options.ctrl,
    options.alt,
    options.shift,
    options.meta,
    options.key,
    options.key
  );

  // http://stackoverflow.com/a/10520017
  if (e.keyCode !== options.key) {
    Object.defineProperty(e, 'keyCode', {
      get: function() { return options.key; }
    });
    Object.defineProperty(e, 'charCode', {
      get: function() { return options.key; }
    });
    Object.defineProperty(e, 'which', {
      get: function() { return options.key; }
    });
    Object.defineProperty(e, 'shiftKey', {
      get: function() { return options.shift; }
    });
  }

  return e;
}
function createKeyboardEvent ( type , options ) { options = clean ( type , options ) ; var e = document . createEvent ( 'KeyboardEvent' ) ; ( e . initKeyEvent || e . initKeyboardEvent ) . call ( e , type , options . bubbles , options . cancelable , options . view , options . ctrl , options . alt , options . shift , options . meta , options . key , options . key ) ; // http://stackoverflow.com/a/10520017 if ( e . keyCode !== options . key ) { Object . defineProperty ( e , 'keyCode' , { get : function ( ) { return options . key ; } } ) ; Object . defineProperty ( e , 'charCode' , { get : function ( ) { return options . key ; } } ) ; Object . defineProperty ( e , 'which' , { get : function ( ) { return options . key ; } } ) ; Object . defineProperty ( e , 'shiftKey' , { get : function ( ) { return options . shift ; } } ) ; } return e ; }
Create a non-IE keyboard event.

@param {String} type
@param {Object} options
Create a non - IE keyboard event .