I have looked at a bunch of answers to a previous question I had (it was answered), but something that I kept seeing were methods like:
public void keyPressed(KeyEvent e)
but none ever showed where these methods were used, so I never figured out what to do with the argument.
Example:
public void keyPressed(KeyEvent e, Robot r) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_W) {
r.keyPress(KeyEvent.VK_R);
r.mousePress(InputEvent.BUTTON1_MASK);
try { Thread.sleep(100); } catch (Exception s) {}
r.mouseRelease(InputEvent.BUTTON1_MASK);
}
}
public static void autoCliker() throws AWTException, InterruptedException
{
Robot r = new Robot();
while(KeyPressed(not sure what to do here, r)//this is what my question is about
{
Thread.sleep(10);
r.keyPress(KeyEvent.VK_R);
r.mousePress(InputEvent.BUTTON1_MASK);
try { Thread.sleep(100); } catch (Exception e) {}
r.mouseRelease(InputEvent.BUTTON1_MASK);
}
}
It's more about how to use an Event in an argument within a method than about the KeyEvent, I am just using one of my programs as an example.