How would one, once they had set up a Keylistener or Keyadapter class and had overridden keyPressed and the other two, get the keyboard response in their program working? For example, say I have my Keyadapter class all set up:
public class KeyInput extends Keyadapter {
public void keyPressed (KeyEvent e) {
int key = e.getKeyCode();
if (key == VK_W) {
System.out.println("You pressed W");
}
}
}
How would I go from there, to make it so it would actually detect it and display the string whenever I would press W? There aren't any methods that I could call in the main method to make it start checking, are there? If not how does the JVM know to start checking if there isn't a method in main to tell it to?
Thank you for your time.