If I get your question right, this is what you are looking for
<html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).keydown(function(event){ if(event.keyCode == 13){ alert("keypressed"); } }); function clickevent() { var e = $.Event("keydown"); e.which = 13; e.keyCode = 13; $(document).trigger(e); } </script> </head> <body id="thebody"> <input type="button" onclick="clickevent()" value="click me first"> </body> </html>
themis
source share