Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to listen to keyboard events in a console application

Tags:

java

Now, I'm developing a command-line application somewhat like bash. For implementing the autocomplete functionality, I must know users have pressed Tab key. But i don't know how to listen to keyboard events in a console application.

any ideas? Thanks in advance.

like image 685
Alanmars Avatar asked Jan 22 '26 10:01

Alanmars


1 Answers

This is slightly more complicated than it looks.

Maybe you should have a look at the jline project that handles everything for you.

like image 175
Nicolas Modrzyk Avatar answered Jan 25 '26 01:01

Nicolas Modrzyk