old_contents: (function() {
    try {
      return new KeyboardEvent(eventType, init);
    } catch (error) {
      global.window.KeyboardEvent = function(eventType, init) {
        var modKeys = [
          init.ctrlKey ? 'Control' : '',
          init.shiftKey ? 'Shift' : '',
          init.altKey ? 'Alt' : '',
          init.altGrKey ? 'AltGr' : '',
          init.metaKey ? 'Meta' : '',
        ].join(' ');
        var keyEvent = document.createEvent('KeyboardEvent');
        keyEvent.initKeyboardEvent(
          eventType,
          false,
          false,
          window,
          init.char || '',
          init.keyCode || 0,
          modKeys,
          init.repeat || false
        );
        keyEvent.key = init.key;
  
        return keyEvent;
      }
    }
  })();
  
new_contents: (function() {
    // critically in Phantom JS it is an object so can't be used as a constructor.
    if (typeof KeyboardEvent !== 'function') {
      global.window.KeyboardEvent = function(eventType, init) {
        var modKeys = [
          init.ctrlKey ? 'Control' : '',
          init.shiftKey ? 'Shift' : '',
          init.altKey ? 'Alt' : '',
          init.altGrKey ? 'AltGr' : '',
          init.metaKey ? 'Meta' : '',
        ].join(' ');
        var keyEvent = document.createEvent('KeyboardEvent');
        keyEvent.initKeyboardEvent(
          eventType,
          false,
          false,
          window,
          init.char || '',
          init.keyCode || 0,
          modKeys,
          init.repeat || false
        );
        keyEvent.key = init.key;
  
        return keyEvent;
      }
    }
  })();
  
subject: Check for type then fill.