My editor (VS Code) shows that my variable is deprecated. The "event" variable is struck out, but in my prof's video, it isn't so I'm assuming something is wrong. Please help!
document.querySelector("#myCanvas").onclick = function(){
console.log("click", event);
}
I called the variable in the function which fixed it, but now I'm trying to do "onkeydown" and nothing is happening when I refresh the HTML
document.querySelector("#myCanvas").onmousemove = function(event){
// console.log(event.offsetX, event.offsetY);
// console.log("click", event);
}
document.onkeydown = function(){
console.log("keypress" ,event);
}
The "global" event property (i.e., window.event) is deprecated. Why is it global here? Because you didn't pass the event returned by the onclick callback to your onclick event handler, like this:
document.querySelector("#myCanvas").onclick = function(event) {
console.log("click", event);
}