title: Trigger keyboard shortcut via Javascript mouse button click event
body: <p>I need the ability for users on an internal intranet site to click a button and open their file search, which is the <kbd>Ctrl</kbd> + <kbd>O</kbd> keyboard command. Ideally I need them to click a button to open a particular local file folder, but I know this isn't possible on Chrome without an extension. </p>
  
  <p>How can I trigger the <kbd>Ctrl</kbd> + <kbd>O</kbd> command via JavaScript?</p>
  
  <p>I found the following:</p>
  
  <blockquote>
    <p><a href="https://stackoverflow.com/questions/22650342/trigger-a-keyboard-shortcut-through-mouse-click-event-using-jquery">Trigger a keyboard shortcut through mouse click event using jQuery</a></p>
  </blockquote>
  
  <p>But I don't understand where the alt key command is being instigated?</p>
  
  <p>**Edit:</p>
  
  <p>Which part of the following calls the alt key and the n key? I see the e.which is 110, but all I can find of the keyCode lists is that 110 cooresponds to the decimal point key. (Such as <a href="https://css-tricks.com/snippets/javascript/javascript-keycodes/" rel="nofollow noreferrer">here</a>, <a href="http://keycode.info/" rel="nofollow noreferrer">here</a>, etc)</p>
  
  <p>I'm using <code>jQuery(document)</code> due to Wordpress restriction.</p>
  
  <pre><code>jQuery(document).ready(function($){
  
      $(document).on( 'keypress', 'body', function( e ){
          var code = e.keyCode || e.which;
  
          if( code = 110 ) {
              console.log( 'Successfully triggered ALT+N' );
          }
      });
  
      $(document).on( 'click', '#copy', function(  ){
          var e = $.Event('keypress');
          e.which = 110; // Character 'A'
          console.log( e );
          $('body').trigger(e);
      });
  
  });
  </code></pre>