Creating Snake Code

I feel so rude doing this, but this part of the code seems to be malfunctioning this was how I did it several times before too. How would I fix this problem?

void keyPressed() {
  if (key==CODED) {
    switch(keyCode) {
    case UP:
      setDirection('u');
      break;
    case DOWN:
      setDirection('d');
      break;
    case LEFT:
      setDirection('l');
      break;
    case RIGHT:
      setDirection('r');
      break;
    }
  }
}
1 Like