I am trying to allow my user to hit enter in the input field which should trigger the same click event as if they had clicked on the "submit" button with their mouse.
document.getElementById("input").addEventListener("keyup", function() {
if (KeyboardEvent.code == "13") {
document.getElementById("button").click();
}
});
However the keycode doesn't work. The content of the function works when I do KeyboardEvent.code != "13" but I don't know how to make it listen to only the enter key.
I have tried looking t other questions on Stackoverflow (notably here), but my code editor is saying those notations are deprecated.