# Using keyboard events

**URL:** <https://discourse.processing.org/t/using-keyboard-events/24503>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [October 10, 2020, 8:28pm UTC](https://discourse.processing.org/t/using-keyboard-events/24503 "2020-10-10T20:28:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thughes](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@thughes](https://discourse.processing.org/u/thughes)\
**Post date:** [October 10, 2020, 8:28pm UTC](https://discourse.processing.org/t/using-keyboard-events/24503/1 "2020-10-10T20:28:17Z")

</div>

Advice please:

**public void change** This function will increment the y2 of the 2nd ellipse by 2. Use the short cut operator for the assignment. If the y2 is greater than height, reset the y2 to 30.

this is what i have so far–

```auto
public void change()
{
if (y2>height);
}

```

---

<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:** [October 10, 2020, 9:13pm UTC](https://discourse.processing.org/t/using-keyboard-events/24503/2 "2020-10-10T21:13:41Z")

</div>

> [@thughes](#):
>
> short cut operator

What is this? What do you think?

---

<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:** [October 10, 2020, 9:15pm UTC](https://discourse.processing.org/t/using-keyboard-events/24503/3 "2020-10-10T21:15:21Z")

</div>

See [https://processing.org/reference/conditional.html](https://processing.org/reference/conditional.html)

---

<div class="post-metadata">

**Author:** ![thughes](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@thughes](https://discourse.processing.org/u/thughes)\
**Post date:** [October 10, 2020, 9:16pm UTC](https://discourse.processing.org/t/using-keyboard-events/24503/4 "2020-10-10T21:16:52Z")

</div>

okay…i figured that part out…

where would i look to find out how to make my ellipse move up and down?

create a program that creates two balls using the ellipse function. One will be controlled by the keyboard using the UP, DOWN, LEFT, RIGHT keys. **The other will fall vertically and return to a random x location at the top if it reaches the bottom**

---

<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:** [October 11, 2020, 7:00am UTC](https://discourse.processing.org/t/using-keyboard-events/24503/5 "2020-10-11T07:00:34Z")

</div>

Look, make yourself familiar with the examples.

Otherwise you will keep asking for every single small step.

We already pointed you to the motion section of the example section of the website

See [https://processing.org/examples/linear.html](https://processing.org/examples/linear.html)

---

<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:** [October 11, 2020, 7:02am UTC](https://discourse.processing.org/t/using-keyboard-events/24503/6 "2020-10-11T07:02:11Z")

</div>

> [@thughes](#):
>
> `if (y2>height);`

NEVER make a ; at this point

it ends the if clause.

* * *

**Example**

As an example

compare this correct code :

```auto
if (3==4) 
  println("True");
println("End");

```

with this wrong code:

```auto
if (3==4);
   println("True");
println("End");

```

Do you see the problem? Exactly.
