Using jQuery to listen to keydown event
If you want to capture the keypress anywhere on the page – $(document).keypress(function(e) { if(e.which == 13) { // enter pressed } }); Don’t worry about the fact this checks for every keypress, it really isn’t putting any significant load on the browser.