In java, the keypress in console requires an "enter" to register the entry, at least with Scanner userInput. I tried simulating the enter keypress to overpass this but its dumb, at the end i need to see if "G" Was Keypressed. So im looking for a shorty understandable code to see if "G" was pressed to start the event. This is the code i have right now but it requires an enter press.
public void WaitGetImput()
{
start();
Scanner userInput = new Scanner(System.in);
while(!userInput.hasNext());
String input = "";
if (userInput.hasNext()) input = userInput.nextLine();
if (input.equals("g"))
{
stop();
System.out.println("Took "+getSeconds() +" Seconds.");
}
}
Start and stop are functions to start and stop a chronometer to see how much time it took. Thats why i need to bypass the enter, the enter takes time and gives a wrong read of the real reaction time. If anybody has an idea, please include he libraries to add. Im kind of a begginner in java but i've coded much in all kind of C and in python. Until now i didnt find anything that worked and was understandable at the same time, help!
Edit: Gonna learn libGDX to make it work so this topic is closed. Thanks for the help!