# Need help with this code

**URL:** https://discourse.processing.org/t/need-help-with-this-code/27791
**Category:** Coding Questions
**Created:** [February 13, 2021, 2:17pm UTC](https://discourse.processing.org/t/need-help-with-this-code/27791 "2021-02-13T14:17:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![LxnaDark](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@LxnaDark](https://discourse.processing.org/u/LxnaDark)
#### Post date: [February 13, 2021, 2:17pm UTC](https://discourse.processing.org/t/need-help-with-this-code/27791/1 "2021-02-13T14:17:42Z")

</div>

I want the characters I type to be printed. When I press a letter key and SHIFT, I just want an upper letter to be printed.

The problem is, when I press a letter key and shift, the upper version of this letter is printed twice. Why is it printed twice? I just want it to be printed once.

And I don’t want to use void keyPressed().

This is my code:

```auto
void draw() {
  if (keyPressed) {
    if (keyCode == SHIFT) {
        keyPressed = false;      
    } else {
      print(key);
      keyPressed = false;
    }
  }
}

```

Thanks in advance 🙂

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [February 13, 2021, 2:22pm UTC](https://discourse.processing.org/t/need-help-with-this-code/27791/2 "2021-02-13T14:22:41Z")

</div>

Did you try

**if (key != CODED)**

See [keyCode \ Language (API) \ Processing 3+](https://processing.org/reference/keyCode.html)

---

<div class="post-metadata">

### Author: ![SNICKRS](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@SNICKRS](https://discourse.processing.org/u/SNICKRS)
#### Post date: [February 13, 2021, 4:28pm UTC](https://discourse.processing.org/t/need-help-with-this-code/27791/3 "2021-02-13T16:28:46Z")

</div>

It would be better to use the getKeyCode() function within keyAdapter, check that code, and print the actual key. Otherwise, it would be better to use the key != CODED boolean within the processing development environment. Here is an implementation:

```auto
String code = "";
String[] words;
void draw() {
  words = code.split("/");
  println(words);
}
void keyPressed() {
  if (key != ' ') {
    if (keyCode == SHIFT) {
      String k = Character.toString(key);
      k = k.toUpperCase();
      code += k;
    } else {
      code += key;
    }
  } else {
    code += "/";
  }
}

```
