我想记录是否按了空格键。看起来应该是这样的:
public static void main(String[] args) {
for (int i = 1; i < 100; i++) {
if(space is pressed){ //asks if key is pressed
System.out.println("1");
}else {
System.out.println("0");
}
try {
Thread.sleep(5000); //5000 milliseconds delay
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}