# Multiple key listener problem

**URL:** <https://forum.kirupa.com/t/multiple-key-listener-problem/247629>\
**Category:** flash\
**Created:** [December 27, 2007, 2:59pm UTC](https://forum.kirupa.com/t/multiple-key-listener-problem/247629 "2007-12-27T14:59:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SolBrad](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@SolBrad](https://forum.kirupa.com/u/SolBrad)\
**Post date:** [December 27, 2007, 2:59pm UTC](https://forum.kirupa.com/t/multiple-key-listener-problem/247629/1 "2007-12-27T14:59:33Z")

</div>

Hi all,

i am having a problem with key listeners and i am hoping someone can point me in the right direction.

The problem is that i need to monitor 2 keys at the same time, the down arrow to make my object run, and the space bar to make it jump

I currently have the down key set to increase speed, which works fine

if(Key.getCode() == Key.DOWN)  
{  
\_global.speed++;  
}

Then inside the same keylistener i have the following

if(Key.getCode() == Key.SPACE)  
{  
\_root.runner.gotoAndPlay(28);  
}

so all in all the code with the listener looks like so

var KeyListener:Object = new Object();  
KeyListener.onKeyUp = function() {  
if(Key.getCode() == Key.SPACE)  
{  
\_root.runner.gotoAndPlay(28);  
}  
if(Key.getCode() == Key.DOWN)  
{  
\_global.speed++;  
}  
};  
Key.addListener(KeyListener);

the problem is, if i am tapping the down key to increase the speed, i cannot press the space bar at the same time, i need to stop tapping the down key

I tried making its own keyListener but that had no change

Any ideas on how to fix this problem?  
Any help would be greatly appreciated

Thanks
