I want to write a Snake game in Java. How can I continuously monitor input and if user pressed
W set variable
Char lastDirection = 'w'; //hence, Direction.UP?
I know about the Scanner method:
Scanner scan= new Scanner(System.in);... But then user would have to hit enter each time he presses the button. Document Listener (Swing) seems better, but then I would have a long string of user input saved somewhere that I don't need. What is the right method for listening to keyboard and remembering the last character?