How many keystrokes can Flash detect? using as3

I am developing a small game. I use the following code to detect keystrokes:

private function onKeyDown(event:KeyboardEvent):void {
        //moviment keys
        if (event.keyCode == 37 || event.keyCode == 65) {
            this.leftKeyPressed = true;
        }
        if (event.keyCode == 39 || event.keyCode == 68) {
            this.rightKeyPressed = true;
        }
        if (event.keyCode == 38 || event.keyCode == 87) {
            this.upKeyPressed = true;
        }
        if (event.keyCode == 40 || event.keyCode == 83) {
            this.downKeyPressed = true;
        }

        if (event.keyCode == this.shootKey) {
            this.shootKeyPressed = true;
        }
    }

OnKeyUp event:

private function onKeyUp(event:KeyboardEvent):void {
        if (event.keyCode == 37 || event.keyCode == 65) {
            this.leftKeyPressed = false;
        }
        if (event.keyCode == 39 || event.keyCode == 68) {
            this.rightKeyPressed = false;
        }
        if (event.keyCode == 38 || event.keyCode == 87) {
            this.upKeyPressed = false;
        }
        if (event.keyCode == 40 || event.keyCode == 83) {
            this.downKeyPressed = false;
        }
        if (event.keyCode == this.shootKey) {
            this.shootKeyPressed = false;
        }
        if (event.keyCode == changeColorKey) {
            trace('color key released');
            trace(getTimer());
            this.changeColorKeyPressed = true;
        }

    }

Basically the shooting will be held by the player almost all the time. And changeColorKey will be pressed very often, but not held. During testing, I noticed that while holding the shootKey button and the right arrow, the onKeyUp events for changeColorKey do not fire. Holding the up or down arrow instead of the right arrow has the same effect. If I hold the left arrow key, events fire. Why is this happening? Is there something wrong with my code?

+5
source share
3

, , , . , , . , , , , , , (, , - ).

+4

, . , , usb.

, . ! , , , , , .

, , KEY_UP, KEYed_DOWN ( ) , KEYing_UP ( key_up ). , . , , , changeColorKey, - ( , - , ), .

shootKey / changeColorKey - , , .

+2

Keypoll, : http://code.google.com/p/bigroom/wiki/KeyPoll.

As for how many keys you can hold, I'm not sure, but try using ctrl, shift, as usual, is not taken into account (I have not tested this in Flash / ActionScript).

+1
source

All Articles