You can’t detect an event in the command line environment. You should provide a GUI, and then you can use the KeyListener
class to detect a keyboard event.
Alternatively you can read commands from standard input and then execute a proper function.
More Related Contents:
- What is the difference between "collection" ,"Collection" and "Collections"? [duplicate]
- PersistentObjectException: detached entity passed to persist thrown by JPA and Hibernate
- Unable to compile simple Java 10 / Java 11 project with Maven
- What are classes, references, and objects?
- Java Byte Array to String to Byte Array
- Which is the best alternative for Java Serialization?
- Parse JSON file using GSON
- Cannot load image in JavaFX
- How to do query auto-completion/suggestions in Lucene?
- Android Center text on canvas
- method called after release() exception unable to resume with android camera
- Why after logout clicking back button on the page displays previous page content?
- how to update xml file from another xml file dynamically?
- Referencing Environment Variables in web.xml
- java.lang.ClassCastException
- Why do you have to call URLConnection#getInputStream to be able to write out to URLConnection#getOutputStream?
- How to serialize object to CSV file?
- org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList; with Selenium 3.5.3 Chrome 76
- How to exclude an element from a Firestore query?
- How to disable push-notifications using Selenium for Firefox and Chrome?
- What is the use of printStackTrace() method in Java?
- Java balanced expressions check {[()]}
- Spring 3.0 making JSON response using jackson message converter
- cucumber throwing java.lang.NoClassDefFoundError: io/cucumber/core/gherkin/FeatureParser
- How can I make my AES encryption identical between Java and Objective-C (iPhone)?
- Printing out a 2D array in matrix format
- Testing console based applications/programs – Java
- org.dbunit.dataset.NoSuchTableException: Did not find table ‘xxx’ in schema ‘null’
- Android: Navigation-Drawer on all activities
- JavaFX Spell checker using RichTextFX how to create right click suggestions