The current Java JDK API does not allow reading single key strokes from the console. Console input is only supported in line mode. JLine supports reading single keys, but not without blocking, and it's a large and complex package.
RawConsoleInput class uses JNA
to call operating system functions of Windows and Unix/Linux.
RawConsoleInputand normal line-mode console input (e.g. using
System.console().readLine()) can be mixed. But on Unix, resetConsoleMode() has to be called to switch the console back to normal input mode.
Source code: RawConsoleInput.java
Author: Christian d'Heureuse (www.source-code.biz, www.inventec.ch/chdh)