I want to check whether the escape key has been pressed/released in javascript.
They way I've seen is this :
document.addEventListener('keyup', function(event) {
//returns a number for key
console.log(event.keyCode);
});
However when I went onto Mozilla it says the '.keyCode' is being deprecated use '.key' instead. Which I did but when I changed the code to this:
document.addEventListener('keyup', function(event) {
//returns a number for key
console.log(event.key);
});
It wouldn't work it said in the console 'undefined'. Any ideas why?
Also is Mozilla the best place to go, because as a beginner I'm finding it difficult to understand. Thanks