# Losing key press detectiong when button is clicked

**URL:** <https://forum.kirupa.com/t/losing-key-press-detectiong-when-button-is-clicked/314926>\
**Category:** flash\
**Created:** [October 12, 2010, 3:01pm UTC](https://forum.kirupa.com/t/losing-key-press-detectiong-when-button-is-clicked/314926 "2010-10-12T15:01:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![felipegm](https://avatars.discourse-cdn.com/v4/letter/f/e9bcb4/32.png) [@felipegm](https://forum.kirupa.com/u/felipegm)\
**Post date:** [October 12, 2010, 3:01pm UTC](https://forum.kirupa.com/t/losing-key-press-detectiong-when-button-is-clicked/314926/1 "2010-10-12T15:01:33Z")

</div>

Hello

i’m building an projector application in AS3, as a slide show.

When the right and left keys are pressed on the keyboard, the slides change.

the code to change the slide:

```auto

function setup() {
	stage.addEventListener(KeyboardEvent.KEY_DOWN, displayKey);
}
setup();

function displayKey(keyEvent:KeyboardEvent) {

	if (keyEvent.keyCode==37) {
		prev();
	} else if (keyEvent.keyCode == 39) {
		next();
	}

}

```

Some slides have button on it, that change the slide, jumping to a chapter the user whant to see.

the problem i’m having is that when the button at a slide is clicked, the key press detection does not work anymore. To make it work, I have to click somewhere on the stage.

Does anybody has gone trough something like this before?  
If so, any help will be appreciated.

Thanks
