# Recognizing specific keys in keyboardEvent

**URL:** <https://forum.kirupa.com/t/recognizing-specific-keys-in-keyboardevent/275406>\
**Category:** flash\
**Created:** [November 13, 2008, 2:35pm UTC](https://forum.kirupa.com/t/recognizing-specific-keys-in-keyboardevent/275406 "2008-11-13T14:35:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jet\_jmu](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jet\_jmu](https://forum.kirupa.com/u/jet_jmu)\
**Post date:** [November 13, 2008, 2:35pm UTC](https://forum.kirupa.com/t/recognizing-specific-keys-in-keyboardevent/275406/1 "2008-11-13T14:35:24Z")

</div>

Hey guys, I just joined the forum because I’m having trouble with a project. I want to have certain keys on a keyboard correspond to a trumpet movie clip on the stage. I’ve gotten to the point where the valve goes down if you press any key on the keyboard, but I want it to only work if you press a specific key. I know that this was pretty simple in AS2 with the Key.isDown function, but I’m looking for a way to do it with AS3. Here’s the code that I have so far-

function reportKeyDown(event:KeyboardEvent):void  
{  
valve1\_mc.gotoAndStop(“down”);  
}

stage.addEventListener(KeyboardEvent.KEY\_DOWN, reportKeyDown);

function reportKeyUp(event:KeyboardEvent):void  
{  
valve1\_mc.gotoAndStop(“up”);  
}

stage.addEventListener(KeyboardEvent.KEY\_UP, reportKeyUp);

Thanks for your help!
