Can someone please explain to why nothing happens when I press enter when I am in the
the textbox?
<script>
function buttonCode(){
alert("Button code executed.") }
var input = document.getElementById("userinput");
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13){
event.preventDefault();
document.getElementById("button1").click();
}
});
</script>
<body>
<input id="userinput" type ="text">
<button id="button1"
onclick = "buttonCode()"
>
Button
</button>
</body>