As the title suggests, in my Java game, I cannot detect if I'm pressing the spacebar and other keys at the same time.

For example, spacebar is the shoot key, and the arrow keys make the player move. If I am pressing the up arrow key and the left arrow key and the spacebar, then it should shoot a bullet up and to the left.

However, after using multiple `System.out.println();` to debug, I've found that if I am pressing two keys, it is not detecting the spacebar if it's pressed.

```
public void keyPressed(KeyEvent e) {

if(e.getKeyCode() == 32){
    pressingSpacebar = true;
    System.out.println("Spacebar pressed true");
}

    // Up arrow key
    if(e.getKeyCode() == 38){
        up = true;
        System.out.println("Up = true");
    }
    // Down arrow key
    if(e.getKeyCode() == 40){
        down = true;
        System.out.println("Down = true");

    }
    // Right arrow key
    if(e.getKeyCode() == 39){
        right = true;
        System.out.println("Right = true");
    }
    // Left arrow key
    if(e.getKeyCode() == 37){
        left = true;
        System.out.println("Left = true");
    }
}

```

Then in keyReleased:

```
public void keyReleased(KeyEvent e) {
    if(e.getKeyCode() == 38){
        up = false;
        repaint();
    }
    if(e.getKeyCode() == 40){
        down = false;
        repaint();
    }
    if(e.getKeyCode() == 39){
        right = false;
        repaint();
    }
    if(e.getKeyCode() == 37){
        left = false;
        repaint();
    }
    if(e.getKeyCode() == 32){
        pressingSpacebar = false;
    }
}

```

This is how I am checking if you are pressing the spacebar and multiple keys:

```
if(pressingSpacebar){
        if(right == true && down == true && up == false && left == false){
            // Shoot bullet
        }
}   

```

Why isn't the spacebar being detected? If I don't check for spacebar being pressed the bullets shoot fine, but when I check for the spacebar it just doesn't detect it. 

Note: I have read other posts similar to this question but the answers were not very helpful. I am a sorta newbie when it comes to this stuff so try to give a simple answer or explain it a bit. Thanks in advance!