function direction(event) {
    if (event.keyCode == 37 && dir != "RIGHT")
        dir = "LEFT";
    if (event.keyCode == 38 && dir != "DOWN")
        dir = "UP";
    if (event.keyCode == 39 && dir != "LEFT")
        dir = "RIGHT";
    if (event.keyCode == 40 && dir != "UP")
        dir = "DOWN";

}
//Seting the direction being pressed by arrow keys

Seting the direction being pressed by arrow keys
Seting the direction being pressed by arrow keys
function direction(event) {
    if (event.keyCode == 37 && dir != "RIGHT")
        dir = "LEFT";
    if (event.keyCode == 38 && dir != "DOWN")
        dir = "UP";
    if (event.keyCode == 39 && dir != "LEFT")
        dir = "RIGHT";
    if (event.keyCode == 40 && dir != "UP")
        dir = "DOWN";
}
function direction ( event ) { if ( event . keyCode == 37 && dir != "RIGHT" ) dir = "LEFT" ; if ( event . keyCode == 38 && dir != "DOWN" ) dir = "UP" ; if ( event . keyCode == 39 && dir != "LEFT" ) dir = "RIGHT" ; if ( event . keyCode == 40 && dir != "UP" ) dir = "DOWN" ; }
Seting the direction being pressed by arrow keys
Seting the direction being pressed by arrow keys