Not sure if I asked the question right but I am using keylistener for keyboard inputs in keyboard.java. I want to call the keyboard.java file in the display.java (main class) so that when I run the display class, I press a key and print something out to test it. Here is the code for the keyboard.java file:
public class Keyboard implements KeyListener {
@Override
public void keyTyped(KeyEvent event) {
}
@Override
public void keyPressed(KeyEvent event) {
int key = event.getKeyCode();
if(key == KeyEvent.VK_E) {
System.out.println("E pressed");
}
}
@Override
public void keyReleased(KeyEvent event) {
}
}
I already typed in private Keyboard keyboard;
into the display class but nothing is happening when I press the E key. I need help and I am using Eclipse (Im new to java).