# Functions on Key Press

**URL:** <https://forum.kirupa.com/t/functions-on-key-press/288247>\
**Category:** flash\
**Created:** [May 13, 2009, 11:04am UTC](https://forum.kirupa.com/t/functions-on-key-press/288247 "2009-05-13T11:04:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattj0070](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mattj0070](https://forum.kirupa.com/u/mattj0070)\
**Post date:** [May 13, 2009, 11:04am UTC](https://forum.kirupa.com/t/functions-on-key-press/288247/1 "2009-05-13T11:04:55Z")

</div>

I am creating a driving game using the following method to drive the car forward:

if (Key.isDown(Key.UP)) {  
speed += 1;  
}

I also want to call a function when the key is pressed athough if I add a function call the function gets repeated as long as the key is pressed and I only require it to run once?

Can anyone help?

Cheers
