# How do I exucate an action only once when a key is pressed constantly?

**URL:** <https://forum.kirupa.com/t/how-do-i-exucate-an-action-only-once-when-a-key-is-pressed-constantly/155722>\
**Category:** Uncategorized\
**Created:** [July 19, 2005, 9:04pm UTC](https://forum.kirupa.com/t/how-do-i-exucate-an-action-only-once-when-a-key-is-pressed-constantly/155722 "2005-07-19T21:04:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![beenetto](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@beenetto](https://forum.kirupa.com/u/beenetto)\
**Post date:** [July 19, 2005, 9:04pm UTC](https://forum.kirupa.com/t/how-do-i-exucate-an-action-only-once-when-a-key-is-pressed-constantly/155722/1 "2005-07-19T21:04:24Z")

</div>

could somebody helpme with this one?

I would like to perform an action only once when I’m holding down a key.  
In my case the arrow keys. The problem is when I place the statments  
inside the Keylistener functions it exucate them constantly.  
So. How do I exucate them only once while the key is not released?  
here is the script

if (Key.isDown(Key.LEFT)) {  
\_root.car\_mc.attachMovie(“MCball”, “ball\_mc”, 1);

```
}
```
