# Using KeyCodes/Event Listeners to naviaget prev/next label

**URL:** https://forum.kirupa.com/t/using-keycodes-event-listeners-to-naviaget-prev-next-label/269212
**Category:** flash
**Created:** [August 24, 2008, 8:25pm UTC](https://forum.kirupa.com/t/using-keycodes-event-listeners-to-naviaget-prev-next-label/269212 "2008-08-24T20:25:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![webpoppy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@webpoppy](https://forum.kirupa.com/u/webpoppy)
#### Post date: [August 24, 2008, 8:25pm UTC](https://forum.kirupa.com/t/using-keycodes-event-listeners-to-naviaget-prev-next-label/269212/1 "2008-08-24T20:25:43Z")

</div>

Hi there, hope someone can help me. The code I’ve posted below effectively navigates from frame label to frame label using a mouse click eventListener. What has me stumped is I need to alter the code so specific keyboard presses trigger the navigation instead of mouse events, similar to powerpoint functionality:

Next label = keycode 40 & 32 ( Down arrow and space bar)  
Previous frame (back to last bullet item) = keycode 38 (up arrow)

I made a vain attempt using KeybaordEvent, but this detects any keyboard action, not a specific key. Unfortunately, this is just a tad beyond my skillset so I would really appreciate some assistance!

stage.addEventListener(MouseEvent.CLICK, seekNextLabel);  
stage.addEventListener(KeyboardEvent.KEY\_UP, prevFrameLabel);

/_move forward to next label… need to use DOWN arrow AND space bar  
instead of mouseclick_/

function seekNextLabel(event:MouseEvent) {  
var temp:String = currentLabel;

while(currentLabel == temp && currentFrame \< totalFrames) {  
nextFrame();  
}  
stop();  
if(currentFrame == totalFrames) {  
gotoAndStop(1);  
}  
trace(currentLabel);  
trace(currentFrame);  
}

/_back up one frame from current label (to end of last bullet point)  
uses key\_up event, want to use UP arrow_/

function prevFrameLabel(whichEvent:Event):void {  
var startLabel:String = this.currentLabel;  
while (currentLabel == startLabel) {  
prevFrame();  
if (currentFrame == 1) {  
break;  
}  
}  
trace(currentLabel);  
trace(currentFrame);  
}

Thanks much,  
WP  
:toad:
