Does anyone have any ideas on how to approach this? From searching, everyone says that in Java a keylogger is not possible, because the read() method and its derivatives would still require a newline for input. This means that the user needs to press Enter.
Someone suggested Thread, but I was only up to the point where I call interrupt() on the single thread and I got lost afterward.
The workaround is just to ask the user to press Enter
public boolean pressEnterToContinue() {
boolean enterIsPressed = false;
System.out.println("Press Enter to continue");
try {
System.in.read();
enterIsPressed = true;
}
catch (IOException e) {
System.out.println("Program error.");
System.exit(1);
}
return enterIsPressed;
}
but if you have any other suggestions on how to go about it, I would appreciate it.