# KeyboardEvent issues

**URL:** <https://forum.kirupa.com/t/keyboardevent-issues/324369>\
**Category:** flash\
**Created:** [August 17, 2011, 7:25am UTC](https://forum.kirupa.com/t/keyboardevent-issues/324369 "2011-08-17T07:25:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![s21](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@s21](https://forum.kirupa.com/u/s21)\
**Post date:** [August 17, 2011, 7:25am UTC](https://forum.kirupa.com/t/keyboardevent-issues/324369/1 "2011-08-17T07:25:24Z")

</div>

im planning to create a topdown shooter like in this one [http://fc08.deviantart.net/fs27/f/2008/165/8/2/Top\_Down\_Shooter\_Engine\_by\_ssjskipp.swf](http://fc08.deviantart.net/fs27/f/2008/165/8/2/Top_Down_Shooter_Engine_by_ssjskipp.swf)

the problem occurs when i need to move my character

in AS2, i could just use  
this.onEnterFrame = function(){  
if(Key.isDown(Key.UP)){  
//moves up  
}  
and just do it three more times for the other three directions (down,left,right)

but in AS3, i have to use stage.addEventListener(KeyboardEvent.KEY\_DOWN, functionname);

function functionname(e:KeyboardEvent){  
if(e.keyCode == 38){  
//moves up  
}  
//and create three more for the other three directions  
}

but in here multipke keys cant be pressed simultaneously, sometimes there’s also a liitle lag when i tried to change the direction which will be very uncomfortable for the players

i tried to use the mutiple key method in here [http://kirupa.com/developer/actionscript/multiple\_key\_detection.htm](http://kirupa.com/developer/actionscript/multiple_key_detection.htm)

i copied the required code and the Keydetection class, but i got this error  
5007: An ActionScript file must have at least one externally visible definition.

i googled about it and it seems the keydetection class need to have the package{ on the top  
however, the source code in the example given didn’t need to use the package{

i tried to add the package but it gives this error  
1120: Access of undefined property Key.

seems i have to use the import.flash. but i dont know how to make the class work

any way to solve this, or is there an alternate method? thx alot 🙂
