Source Code:
(back to article)
Submit
Result:
Report an issue
<input type="text" id="inputField" placeholder="Type something..." /> <script> document.getElementById("inputField").addEventListener("keydown", function (event) { alert(`Key pressed: ${event.key}`); this.value = ''; }); </script>