I\'m trying to run a method when the enter key has been pressed. This method is already being used by a button. Basically, when the user fills in a text field and clicks a s
var ENTER_KEY = 13; var user_key; $(document).on('keydown', function(e){ user_key = e.keyCode || e.which if(user_key === ENTER_KEY) { document.querySelector("#button").click(); } });
button