# How to get a turnkey!

**URL:** <https://discourse.processing.org/t/how-to-get-a-turnkey/15716>\
**Category:** Coding Questions\
**Created:** [November 22, 2019, 12:54pm UTC](https://discourse.processing.org/t/how-to-get-a-turnkey/15716 "2019-11-22T12:54:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [November 22, 2019, 1:06pm UTC](https://discourse.processing.org/t/how-to-get-a-turnkey/15716/2 "2019-11-22T13:06:45Z")

</div>

usually the WASD or the UPDOWNLEFTRIGHT keyboard keys are used.  
and set a X/Y position.  
here a version what show both ( 2 objects // even 2 player )

```auto
int p1x,p1y,p2x,p2y;

void setup(){}
void draw(){}

void keyPressed() { //__ we check on KEY operation
  if (keyCode == UP ) p1y--;
  else if (key == 'w' ) p2y--;
  else if (keyCode == DOWN ) p1y++;
  else if (key == 's' ) p2y++;
  else if (keyCode == RIGHT ) p1x++;
  else if (key == 'd' ) p2x++;
  else if (keyCode == LEFT ) p1x--;
  else if (key == 'a' ) p2x--;
  println("after move: 1 ", p1x, ",", p1y, "/ 2 ", p2x, ",", p2y);
} // end keyPressed

```

---

_[View the full topic](https://discourse.processing.org/t/how-to-get-a-turnkey/15716)._
