# onKeyDown issue

**URL:** <https://forum.kirupa.com/t/onkeydown-issue/203391>\
**Category:** flash\
**Created:** [October 10, 2006, 6:30pm UTC](https://forum.kirupa.com/t/onkeydown-issue/203391 "2006-10-10T18:30:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonni](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@tonni](https://forum.kirupa.com/u/tonni)\
**Post date:** [October 10, 2006, 6:30pm UTC](https://forum.kirupa.com/t/onkeydown-issue/203391/1 "2006-10-10T18:30:34Z")

</div>

it’s about a gallery -

previous and next buttons r working correctly, just like

```
tArray = [];
pArray = [];
iArray = [];

```

so I tried to implement

listen = new Object();  
listen.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
prevImage();  
} else if (Key.getCode() == Key.RIGHT) {  
nextImage();  
}  
};  
Key.addListener(listen);

and when pressing the arrow keys it doesn’t load the apropriate image!!

The function is the same for the previous and next buttons - so  
where’s the catch…

What happens with the images is - on the first KeyDown.RIGHT it goes to  
the correct image, on the second it goes back to the first image - and ond the third it skips two images ahead, and likewise for the KeyDown.LEFT.

Is it a matter of removing the listener - and where?

thanx for your time - tonni
