# Help ! keyboard Event error?

**URL:** <https://forum.kirupa.com/t/help-keyboard-event-error/325764>\
**Category:** Uncategorized\
**Created:** [November 3, 2011, 6:25am UTC](https://forum.kirupa.com/t/help-keyboard-event-error/325764 "2011-11-03T06:25:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphaelle](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@raphaelle](https://forum.kirupa.com/u/raphaelle)\
**Post date:** [November 3, 2011, 6:25am UTC](https://forum.kirupa.com/t/help-keyboard-event-error/325764/1 "2011-11-03T06:25:00Z")

</div>

//variables  
var hero:MovieClip;  
var bg:MovieClip;  
var Key:KeyObject = new KeyObject(stage);

stage.addEventListener(Event.ENTER\_FRAME,moveCharacter);

hero.gotoAndStop(‘idle’);  
bg.visible = true;  
//character Movements  
hero.scaleX=-1;

function moveCharacter(e:Event):void  
//function onenter(keyEvent:KeyboardEvent):void  
{

```
if(Key.isDown(Key.RIGHT))
	{
	hero.x+=5;
	hero.scaleX=-1;
	hero.gotoAndStop('walking');
	}
	
else if(Key.isDown(Key.LEFT))
 	{
	hero.x-=5;
	hero.scaleX=1;
	hero.gotoAndStop('walking');
	}
	
else if(Key.isDown(Key.UP))
 	{
	hero.y-=30;
	hero.y+=30;
	hero.gotoAndStop('jump');
	}
else if(Key.isDown(Key.S))
	{
		hero.gotoAndStop('slash');
	}
else if(Key.isDown(Key.A))
	{
		hero.gotoAndStop('special');
	}
else if(Key.isDown(Key.D))
	{
		hero.gotoAndStop('thrust');
	}
else
	{
		hero.gotoAndStop('idle'); 
	}	

```

}

function backScroll():void  
{  
if (hero.walking \< stage.stageHeight)  
{  
back.x+=10;  
}  
}

help ! actually theres no error but the wrong is I have to press down the keys before it move, like slash. have to press keys for 2 seconds i guess… anyone can help me ???  
thnks in advance !
