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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With