# Key repeat function

**URL:** <https://discourse.processing.org/t/key-repeat-function/23358>\
**Category:** Coding Questions\
**Created:** [August 19, 2020, 12:19pm UTC](https://discourse.processing.org/t/key-repeat-function/23358 "2020-08-19T12:19:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rasheeda](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@rasheeda](https://discourse.processing.org/u/rasheeda)\
**Post date:** [August 19, 2020, 12:19pm UTC](https://discourse.processing.org/t/key-repeat-function/23358/1 "2020-08-19T12:19:50Z")

</div>

I have implemented ball bouncing by boundary.

Keypressed function accept arrow key.

How to process keyrepeat when key is kept pressed. Keypressed is generated only when key is released and pressed again.

Appreciate any advice on the subject.

---

<div class="post-metadata">

**Author:** ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)\
**Post date:** [August 19, 2020, 12:36pm UTC](https://discourse.processing.org/t/key-repeat-function/23358/2 "2020-08-19T12:36:52Z")

</div>

Try this in setup() :

```auto
hint(ENABLE_KEY_REPEAT);

```

---

<div class="post-metadata">

**Author:** ![MiguelSanches](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/miguelsanches/32/11172_2.png) [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Post date:** [August 19, 2020, 12:39pm UTC](https://discourse.processing.org/t/key-repeat-function/23358/3 "2020-08-19T12:39:49Z")

</div>

Hi,

Maybe using keyPressed and keyReleased to change a boolean state will help.  
Here is the link to the key functions of processing ([https://processing.org/reference/keyTyped\_.html](https://processing.org/reference/keyTyped_.html))

Hope it helps 🙂

---

<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:** [August 19, 2020, 4:43pm UTC](https://discourse.processing.org/t/key-repeat-function/23358/4 "2020-08-19T16:43:17Z")

</div>

> [@rasheeda](#):
>
> Keypressed function accept arrow key

This is a function keyPressed()

Use the boolean variable keyPressed in draw() instead

if (keypressed) …
