Answers for "onkey enter javascript"

3

hit enter button lick in js

<form>
    <input id="myInput" placeholder="Some text.." value="">
    <input type="submit" id="myBtn" value="Submit">
</form>

<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
    if (event.keyCode === 13) {
        event.preventDefault();
        document.getElementById("myBtn").click();
    }
});
</script>
Posted by: Guest on May-25-2020
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
10

html onkeypress

<input type="text" onkeypress="myFunction()">
Posted by: Guest on July-10-2020

Browse Popular Code Answers by Language