index.js
//keyPressed is an inbuilt function in p5.js

keyPressed is an inbuilt function in p5.js
keyPressed is an inbuilt function in p5 . js
function keyPressed() {
    if(keyCode === UP_ARROW) {
        snake.direction(0, -1);
    } 
    else if (keyCode === DOWN_ARROW) {
        snake.direction(0, 1);
    } 
    else if (keyCode === LEFT_ARROW) {
        snake.direction(-1, 0);
    } 
    else if (keyCode === RIGHT_ARROW) {
        snake.direction(1, 0);
    } else {
        snake.direction(0,0);
    }
}
function keyPressed ( ) { if ( keyCode === UP_ARROW ) { snake . direction ( 0 , - 1 ) ; } else if ( keyCode === DOWN_ARROW ) { snake . direction ( 0 , 1 ) ; } else if ( keyCode === LEFT_ARROW ) { snake . direction ( - 1 , 0 ) ; } else if ( keyCode === RIGHT_ARROW ) { snake . direction ( 1 , 0 ) ; } else { snake . direction ( 0 , 0 ) ; } }
keyPressed is an inbuilt function in p5.js
keyPressed is an inbuilt function in p5 . js
//keyCode is a built in variable in p5.js
 //Move the snake UP.
 //Move the snake DOWN.
 //Move the snake LEFT.
 //Move the snake RIGHT.
