Trigger a keyboard shortcut through mouse click event using 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); }); }); The above piece of code successfully triggers the keyboard shortcut Alt + N on my document. Alt + N keyboard shortcut does a particular action on my web