i am trying to take keyboard inputs to change the boolean's value but keylisteners are not working
those bolleans values will be used later in other class
heres the method i am having issues with
public boolean upPressed, downPressed, leftPressed, rightPressed;
@Override
public void keyPressed(KeyEvent e) {
int code = e.getKeyCode();
if(code == KeyEvent.VK_W){
upPressed = true;}
else if(code == KeyEvent.VK_S){
downPressed = true;}
else if(code == KeyEvent.VK_A){
leftPressed = true;}
else if(code == KeyEvent.VK_D){
rightPressed = true;}
}
i am using a different class which extends JPanel, frame is in a different class and key listener is in a different class and i have this.setFocusable(true);this.addKeyListener(keyH);
and if u want, here's the full code : https://github.com/PROMAN8625/2dGAME