MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / control

Function control

assets/js/AwesomeSnakeGame.js:46–59  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

44
45document.addEventListener("keydown",control)
46function control(e){
47 if (e.keyCode==37&&dir!="right") {
48 dir="left";
49 }else if (e.keyCode==38&&dir!="down") {
50 dir="up";
51 }else if (e.keyCode==39&&dir!="left") {
52 dir="right";
53 }else if (e.keyCode==40&&dir!="up") {
54 dir="down";
55 }else if (e.keyCode==13) {
56 mode=1;
57
58 }
59}
60
61function draw() {
62 ctx.clearRect(0,0,myCanvas.width,myCanvas.height)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected