# Program which draws an \`I\` if no keys are pressed, and an \`E\`or an \`F\`if those keys are pressed

**URL:** <https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207>\
**Category:** Coding Questions\
**Created:** [January 5, 2019, 12:42am UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207 "2019-01-05T00:42:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Umar2003](https://avatars.discourse-cdn.com/v4/letter/u/8e8cbc/32.png) [@Umar2003](https://discourse.processing.org/u/Umar2003)\
**Post date:** [January 5, 2019, 12:42am UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/1 "2019-01-05T00:42:41Z")

</div>

I’m trying to write a program which draws an `I` if no keys are pressed, and an `E`or an `F`if those keys  
are pressed. Use straight lines to draw these letters. The window size is (120,120).

---

<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:** [January 5, 2019, 12:49am UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/2 "2019-01-05T00:49:52Z")

</div>

very good idea,  
show us your code ( in \</\> formatter )  
and detail description of problems or questions.

---

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [January 5, 2019, 4:00pm UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/3 "2019-01-05T16:00:17Z")

</div>

Do you want that somebody code it for you? Do you need help? Be more detailed as kll said

---

<div class="post-metadata">

**Author:** ![Umar2003](https://avatars.discourse-cdn.com/v4/letter/u/8e8cbc/32.png) [@Umar2003](https://discourse.processing.org/u/Umar2003)\
**Post date:** [January 5, 2019, 8:23pm UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/4 "2019-01-05T20:23:19Z")

</div>

Yes I want that somebody code it

---

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [January 5, 2019, 8:24pm UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/5 "2019-01-05T20:24:30Z")

</div>

Ok, ‘challenge’ accepted, Java right?  
(You know that theres text() and no need to draw with lines right?)

---

<div class="post-metadata">

**Author:** ![Umar2003](https://avatars.discourse-cdn.com/v4/letter/u/8e8cbc/32.png) [@Umar2003](https://discourse.processing.org/u/Umar2003)\
**Post date:** [January 5, 2019, 8:44pm UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/6 "2019-01-05T20:44:48Z")

</div>

Yes java and yes I know there’s text and no need to draw with lines

---

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [January 5, 2019, 8:45pm UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/7 "2019-01-05T20:45:27Z")

</div>

```auto
int width = 120;
int height = 120;

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

void draw(){
  background(255);
  if (keyPressed){
    if (key == 'E'){
      line(width/2 -20,20,width/2 - 20,height - 20);
      line(width/2 -20,20,width/2 + 20 , 20);
      line(width/2 -20,height/2,width/2 + 20 , height/2);
      line(width/2 -20,height/2 + 50,width/2 + 20 , height/2 + 50);
    }
    else if (key == 'F'){
      line(width/2 -20,20,width/2 - 20,height - 20);
      line(width/2 -20,20,width/2 + 20 , 20);
      line(width/2 -20,height/2,width/2 + 20 , height/2);
    }
  }
  else{
    line(width/2 - 20,20,width/2 + 20,20);
    line(width/2 ,20,width/2 ,height - 20);
    line(width/2 - 20,height - 20,width/2 + 20,height - 20);
  }
  
}

```

Remember to caps lock bc `key` is case sensitive

---

<div class="post-metadata">

**Author:** ![Umar2003](https://avatars.discourse-cdn.com/v4/letter/u/8e8cbc/32.png) [@Umar2003](https://discourse.processing.org/u/Umar2003)\
**Post date:** [January 5, 2019, 9:39pm UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/8 "2019-01-05T21:39:49Z")

</div>

for the code, if no keys are pressed the program draws an I, but when I press E or F, it draws neither of those letters

---

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [January 5, 2019, 9:43pm UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/9 "2019-01-05T21:43:33Z")

</div>

use caps lock, i made it that if you press uppercase E and uppercase F, but you can add  
if(key == ‘E’ || key == ‘e’){}, so it works for lowercase too

---

<div class="post-metadata">

**Author:** ![Umar2003](https://avatars.discourse-cdn.com/v4/letter/u/8e8cbc/32.png) [@Umar2003](https://discourse.processing.org/u/Umar2003)\
**Post date:** [January 5, 2019, 9:49pm UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207/10 "2019-01-05T21:49:04Z")

</div>

OK it’s working perfectly now.  
Thank you very much for your help
