Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Stream Keyboard Input

I am writing a program that takes commands via the console.

However, I do not want to press "enter" in order to send that command.

I want the code to constantly monitor what I am entering, and execute the code when I am finished.

The commands are coming as text from a speech recognition program, therefore, eliminating the need for the "enter" stroke is pretty key.

Any one have any ideas?

like image 680
David Avatar asked Nov 06 '22 03:11

David


2 Answers

I have recently come to the knowledge of events in java and i believe this would help you. You would just need to associate the speech recognition printing to the screen with an event in java and it would have a listener to listen for the event and when it sees the event it would execute your desired code. I currently have a thread opened where im trying to get some good examples of this, perhaps that will help.

Java Events Question

like image 155
prolink007 Avatar answered Nov 09 '22 13:11

prolink007


Already answered here:

How to read a single char from the console in Java (as the user types it)?

No portable way to do it, depends on your platform.

like image 37
Eric Giguere Avatar answered Nov 09 '22 13:11

Eric Giguere