Answers for "how to press enter key programmatically in javascript"

3

jquery on enter key pressed

//jQuery detect user pressing enter
$(document).on('keypress',function(e) {
    if(e.which == 13) {
        alert('User pressed Enter!');
    }
});
Posted by: Guest on July-31-2019
2

javascript submit form when enter key pressed

//submit form when 'Enter' key is pressed while in myInputID
document.getElementById("myInputID").addEventListener("keyup", function(event) {
    if (event.keyCode === 13) {
    	document.getElementById("myFormID").submit();
		return false;
    }
});
Posted by: Guest on August-02-2019
4

javascript key pressed enter

$('.container').on('keydown', 'input', function(e) {
  if (e.keyCode === 13) {
    e.preventDefault();
  	e.stopImmediatePropagation();
    //Do your stuff...
  }
});
Posted by: Guest on June-11-2020

Code answers related to "how to press enter key programmatically in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language