why does this robot not pres the down key?
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
Robot robot;
void setup() {
size(400, 400);
//Let's get a Robot...
try {
robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
exit();
}
}
void draw() {}
void mousePressed() {
//Press the space key
robot.keyPress(DOWN);
robot.keyRelease(DOWN);
}
void keyPressed() {
//Detect space key presses (to show that it works)
if(key == DOWN) {
println("Down!");
}
}
glv
2
Hello,
Look up keyCode
in the references.
:)
like this?
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
Robot robot;
void setup() {
size(400, 400);
//Let's get a Robot...
try {
robot = new Robot();
} catch (AWTException e) {
e.printStackTrace();
exit();
}
}
void draw() {}
void mousePressed() {
//Press the space key
robot.keyPress(DOWN);
robot.keyRelease(DOWN);
}
void keyPressed() {
//Detect space key presses (to show that it works)
if(key == CODED) {
if(key == DOWN){
println("Space!");
}
}
}
because this is not working @glv