# User Input from KeyBoard

**URL:** https://discourse.processing.org/t/user-input-from-keyboard/5904
**Category:** Coding Questions
**Created:** [November 24, 2018, 9:46pm UTC](https://discourse.processing.org/t/user-input-from-keyboard/5904 "2018-11-24T21:46:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alexac692](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@alexac692](https://discourse.processing.org/u/alexac692)
#### Post date: [November 24, 2018, 9:46pm UTC](https://discourse.processing.org/t/user-input-from-keyboard/5904/1 "2018-11-24T21:46:27Z")

</div>

I am trying to write a code that will return a string as a result of the user pressing 1, 2, or 3 on their keyboard. This is what I have so far but when i press keys nothing happens. What is wrong with my code?

```auto
String choice;
boolean pressed = false;

void setup ()
{
  size (2000, 2000);
  fill (0);
}

void getTable()
{
  choice = getChoice();
  println(choice);
}

void keyPressed()
{
    
    if (key==1)
    choice = "car_status_BMW_323i.csv";
    if (key==2)
    choice = "car_status_Truck_F150.csv";
    if (key==3);
    choice = "exit";
    
    pressed = true;
  
}

String getChoice()
{
  do
  {
    text("make choice 1, 2, 3", 1000, 1000);
  }while (pressed == false);
  
  return choice;

}

```

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [November 24, 2018, 11:51pm UTC](https://discourse.processing.org/t/user-input-from-keyboard/5904/2 "2018-11-24T23:51:03Z")

</div>

Sounds like you need to do some [debugging](https://happycoding.io/tutorials/processing/debugging). Print out the value of `key` to understand how its value works. You also might want to consult [the reference](https://processing.org/reference/).
