I'm making a Chrome Extension that acts as a task list. You can type in any task you want (ex. Buy eggs) and add it to your list. I wanted to allow the user to type in the task and press the "Enter" key to add it to the list. However, I saw that "keycode" has been removed, so I was wondering if there were any other possible solutions to this issue. I've tried using the method below:
<input type="text" name="newtask" value="" spellcheck="false" placeholder="New Task" id="newtask">
<script>
var input = document.getElementById("newtask");
input.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
alert('test');
event.preventDefault();
}
});
</script>
For now, I'm making it so that if the user presses enter in the input/text box, there will be an alert that states "test." However, when I press enter, nothing happens.