screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> </head> <body> <h3>Javascript Trigger Button on Enter Keypress</h3> <input type="text" id="myInput" value="font awesome icons" /> <button id="myButton">Click Me</button> <script> var input = document.getElementById("myInput"); var button = document.getElementById("myButton"); input.addEventListener("keypress", function (event) { if (event.keyCode === 13) {button.click();} }); button.addEventListener("click", function () { var inputValue = input.value; alert("Input value: " + inputValue); }); </script> </body> </html>