Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
My variable is crossed out in Visual Code

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);
}

enter image description here

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);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!