# Event:KeyboardEvent & keyCode problem

**URL:** <https://forum.kirupa.com/t/event-keyboardevent-keycode-problem/280216>\
**Category:** Uncategorized\
**Created:** [January 24, 2009, 9:58am UTC](https://forum.kirupa.com/t/event-keyboardevent-keycode-problem/280216 "2009-01-24T09:58:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ersk](https://avatars.discourse-cdn.com/v4/letter/e/a9a28c/32.png) [@Ersk](https://forum.kirupa.com/u/Ersk)\
**Post date:** [January 24, 2009, 9:58am UTC](https://forum.kirupa.com/t/event-keyboardevent-keycode-problem/280216/1 "2009-01-24T09:58:31Z")

</div>

So I am fairly new to AS3. I have an image moving round the screen so far using arrow keys and that works just fine.

The problem I have is registering the ‘p’ key hit. At the moment it is only registering when I use ‘shift’ along with ‘p’. But I want to be just able to press ‘p’ on its own.

Heres a snippet of my code:

```auto
function KeyUp(event:KeyboardEvent){
     if(event.keyCode == 80){ 
          key_p = false;
     }
}
 
function KeyDown(event:KeyboardEvent){
     if(event.keyCode == 80){ 
          key_p = true;
     }
}

```

This moves an image on the screen at a diagonal so I can visualy see if ‘p’ is being pressed.

```auto
if(key_p == true){
     hero.x += 2;
     hero.y += 2;
}

```

Thanks in advance.
