The Problem: The website I work on has a search submit button inherited on all pages. Some pages have forms with submit buttons. the result: Enter-key click event chaos! Currently, when a user fills a form and clicks the enter key to submit it, the search box submit button is triggered rather than the form button. Therefore, user gets pissed. The Solution: I captured the enter key click event on page load and set what button to be triggered when enter-key is pressed. If a form buttons is visible, click that submit button first. If not, let the enter key trigger the search box submit button as usual. The Code: $(document).bind('keypress',function(e){ if(e.keyCode === 13) { var buttons = $('.continue-button:visible'); if(buttons.filter('#formSubmit').length > 0) buttons.filter('#formSubmit').click(); else if (buttons.filter('.next').length > 0) buttons.filter('.next').click(...