How to input a character without pressing enter? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to input a character without pressing enter?

i want to input a character without pressing enter. i want if user presses any alphabet it should be accepted

26th Jan 2018, 1:58 PM
Nayan Rathour
Nayan Rathour - avatar
2 Answers
+ 2
Try this: while True { char in = (char) System.in.read(); System.out.println("You pressed " + in); }
26th Jan 2018, 2:18 PM
LunarCoffee
LunarCoffee - avatar
+ 1
java
26th Jan 2018, 2:00 PM
Nayan Rathour
Nayan Rathour - avatar