Source Code:
(back to article)
Submit
Result:
Report an issue
<input type="text" id="inputField" placeholder="Type something and press Enter"> <script> document.getElementById('inputField').addEventListener('keypress', function(event) { if (event.key === 'Enter') { alert('You pressed Enter!'); } }); </script>