Hey code for keydown/keyup

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