# Hey code for keydown/keyup

**URL:** https://forum.kirupa.com/t/hey-code-for-keydown-keyup/121129
**Category:** Uncategorized
**Created:** [August 31, 2004, 4:34am UTC](https://forum.kirupa.com/t/hey-code-for-keydown-keyup/121129 "2004-08-31T04:34:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![KrustyJoe](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@KrustyJoe](https://forum.kirupa.com/u/KrustyJoe)
#### Post date: [August 31, 2004, 4:34am UTC](https://forum.kirupa.com/t/hey-code-for-keydown-keyup/121129/1 "2004-08-31T04:34:36Z")

</div>

K if my sprite is running and my code for that lets say the code is

if (Key.isDown(Key.LEFT)) {  
\_root.hero.gotoAndstop(2);  
this.\_xscale = -100;  
}  
if (Key.isDown(Key.RIGHT)) {  
\_root.hero.gotoAndstop(2);  
this.\_xscale = 100;  
}

k for example thats how my guy runs.

now is there some way to incorporate some thing that lets just say while ur running to the right and then u let go of the right key. how do u make the sprite go to idle frame.  
is it something like

if (Key.isDown(Key.RIGHT) && Key.isUP(Key.RIGHT)  
\_root.hero.gotoAndstop(1);  
this.\_xscale = 100;  
}

im not sure exactly wat to do
