Function keyPressed problems

I am trying to make controls to my game. I am very new to javascript and other programming languages. I have made the controls, but they aren’t that smooth. when you take a sharp turn you just stop. Can someone help me making controls where you can turn without it stopping?

function keyPressed() {
   if (keyCode === 83) {
    s.dir(0, 3);
  } else if (keyCode === 68) {
    s.dir(3, 0);
  } else if (keyCode === 65) {
    s.dir(-3, 0);
  } else if (keyCode === 87) {
    s.dir(0, -3);
  }
}

function keyReleased() {
  s.dir(0, 0);
}

http://p5js.org/reference/#/p5/keyIsDown