1// Get the input field
2var input = document.getElementById("myInput");
3
4// Execute a function when the user releases a key on the keyboard
5input.addEventListener("keyup", function(event) {
6 if (event.code === "Enter") {
7 // Cancel the default action, if needed
8 event.preventDefault();
9 // Trigger the button element with a click
10 document.getElementById("myBtn").click();
11 // ...or call a function
12 myFunction();
13 }
14});