# Key up/down problem

**URL:** https://forum.kirupa.com/t/key-up-down-problem/62936
**Category:** programming
**Created:** [September 1, 2004, 7:25pm UTC](https://forum.kirupa.com/t/key-up-down-problem/62936 "2004-09-01T19:25:07Z")
**Posts on this page:** 2
**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: [September 1, 2004, 7:25pm UTC](https://forum.kirupa.com/t/key-up-down-problem/62936/1 "2004-09-01T19:25:07Z")

</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  
\<!-- / message --\>

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 1, 2004, 7:41pm UTC](https://forum.kirupa.com/t/key-up-down-problem/62936/2 "2004-09-01T19:41:18Z")

</div>

To make him go to idle, type:

onClipEvent (keUp) {  
if (Key.getCode() == Key.RIGHT) {  
this.gotoAndStop(“idle”);  
}  
if (Key.getCode() == Key.LEFT) {  
this.gotoAndStop(“idle”);  
}  
}

That should do it :).

P.S. I use to have problems with the keUp factor too.

peace
