2

How to make that the user has pressed any key and the system automatically did get the value and save him in variable (without pressing Enter)? In console.

Mark
  • 88
  • 6
  • 2
    I don't think this is possible without JNI (native code). Java console IO is simple and line oriented, it doen't provide full terminal access. – markspace Sep 09 '18 at 07:51
  • This type of reading from console called raw. You can do this character by character. here is one solution https://stackoverflow.com/questions/1066318/how-to-read-a-single-char-from-the-console-in-java-as-the-user-types-it – M. Doosti Lakhani Sep 09 '18 at 08:16
  • I recommend you to look for a solution that match with your system. Like Windows or Mac. Because this type of things is an OS shell dependent. – M. Doosti Lakhani Sep 09 '18 at 08:19
  • 1
    Welcome to StackOverflow. I suggest that you look at the Linked question https://stackoverflow.com/questions/1066318/how-to-read-a-single-char-from-the-console-in-java-as-the-user-types-it, and if that answers your question, then close this question. – Richard Neish Sep 10 '18 at 08:33

0 Answers0