# Function keyPressed problems

**URL:** <https://discourse.processing.org/t/function-keypressed-problems/7924>\
**Category:** Beginners\
**Created:** [January 29, 2019, 9:16am UTC](https://discourse.processing.org/t/function-keypressed-problems/7924 "2019-01-29T09:16:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hiitisme](https://avatars.discourse-cdn.com/v4/letter/h/9de053/32.png) [@hiitisme](https://discourse.processing.org/u/hiitisme)\
**Post date:** [January 29, 2019, 9:16am UTC](https://discourse.processing.org/t/function-keypressed-problems/7924/1 "2019-01-29T09:16:43Z")

</div>

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?

```auto
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);
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [January 29, 2019, 9:19am UTC](https://discourse.processing.org/t/function-keypressed-problems/7924/2 "2019-01-29T09:19:29Z")

</div>

[http://p5js.org/reference/#/p5/keyIsDown](http://p5js.org/reference/#/p5/keyIsDown)
