Multiple keyboard events at once

Multiple keyboard events at once



I am working on a game in which multiple keys can be pressed at once.
Like FORWARD+UP to aim in corner and along with it FIRE+JUMP

But i am not getting event for the third and the fourth key press.

I have registered key event with this code

	event: cc.EventListener.KEYBOARD,
	onKeyPressed: function (keyCode, event) {
		event.getCurrentTarget().keyEvent(true, keyCode);
	onKeyReleased: function (keyCode, event) {
		event.getCurrentTarget().keyEvent(false, keyCode);
}, this);

Any idea how to implement this?


I am not sure how cocos detects input (I am working on mobile only).

One way (maybe THE way) is to store all events in an array. Then when a touchup happens, remove the previously added key.

Now you know which keys are pressed at any time by looking through the array.