1<form>
2 <input id="myInput" placeholder="Some text.." value="">
3 <input type="submit" id="myBtn" value="Submit">
4</form>
5
6<script>
7var input = document.getElementById("myInput");
8input.addEventListener("keyup", function(event) {
9 if (event.keyCode === 13) {
10 event.preventDefault();
11 document.getElementById("myBtn").click();
12 }
13});
14</script>
15
1$('.container').on('keydown', 'input', function(e) {
2 if (e.keyCode === 13) {
3 e.preventDefault();
4 e.stopImmediatePropagation();
5 //Do your stuff...
6 }
7});