I know this has been discussed million times. I need read charcters from console not waiting for <cr>. System.in.read() waits for <cr>. I can't use java.io.Console yet since compatibility. Please remind me how to read keyboard.
It may have been discussed many times, but the answer is always very simple: you can't do it. Furthermore, java.io.Console doesn't help: it only provides line-buffered-non-echoed reads for reading passwords, not any kind of general console-handling.
There's a library called "JLine" out there that might do this; I'm not sure. It uses native code, as any solution would need to.
Originally posted by Chris Treglio: Could you react to intput made before a CR by subclassing FilterInputStream (with the original System.in as the underlying stream) and using your subclass to manually flush the member "in"?
No. System.in.read() won't return until Enter is pressed, no matter what.