public void onKeyPress(Key key) {
        if (key == Key.UP){
            if (snake.getDirection() == DOWN) return;
            else
                snake.setDirection(UP);
        }

        if (key == Key.DOWN){
            if (snake.getDirection() == UP) return;
            else
                snake.setDirection(DOWN);
        }

        if (key == Key.LEFT){
            if (snake.getDirection() == RIGHT) return;
            else
                snake.setDirection(LEFT);
        }

        if (key == Key.RIGHT){
            if (snake.getDirection() == LEFT) return;
            else
                snake.setDirection(RIGHT);
        }
    }