Assessment wanted for Events 2 skill test

The test requires that I move the circle around the canvas using keys w,a,s,d .I tried using the keydown event, with a function that updates the x and y co-ordinates, but it does not work.

This is a link to my code: https://campsell.w3spaces.com/saved-from-Tryit-2022-10-12.html

This is the link to the task: Test your skills: Events - Learn web development | MDN (mozilla.org)

Thank you in anticipation

Hi @Ibeh_John and welcome to the community :wave:

Here are some hints:

  • Having addEventListener inside an if condition doesn’t really make sense.
  • Your canvas listener should call move when a key is pressed.
  • After updating x or y you need to call the draw function inside move to see the changes.

I hope this will get you further. Please ask if you need more help. :slightly_smiling_face:

Have a nice day,
Michael