Press any key to continue | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Press any key to continue

How can I simulate "Press any Key to continue" without press Enter Key? For example: - "Press any key to continue" - press A key - run program I tried with System.in.read(), but It expected to press Enter key

10th Jun 2019, 11:54 AM
Leo Flame
Leo Flame - avatar
1 Answer
+ 1
That would require unbuffered input and as far as I know, there's no way to toggle buffered input in Java (at least not in a portable way) since it's largely platform dependent. Perhaps there's a Java wrapper for the ncurses library or some other 3rd party equivalence that allows you to do that, but it may be a bit of an overkill in your situation. It's probably better to just roll with the punches.
10th Jun 2019, 12:48 PM
Cluck'n'Coder
Cluck'n'Coder - avatar