0
Computer/keys
How would I make and object move by using the arrow keys.
3 Answers
+ 1
Add keydown event listener:
document.addEventListener("keydown", function(event) {
var key = event.which || event.keyCode;
// Left:Â 37 Up:Â 38 Right:Â 39 Down:Â 40
if(key==37) left();
else if(key==38) up();
else if(key==39) right();
else if(key==40) down();
});
You can do it with or without canvas,
here a normal div element movement, controlled by buttons or keyboard arrows:
https://code.sololearn.com/WiBmEEtaNcxk/?ref=app
0
using canvas and functions which will invoke on particular key event. In ur case that's arrows.
0
YUGABDH PASHTE and how woild i do that



