Java how do you detect tab key press within a non-GUI application?

前端 未结 1 1891
走了就别回头了
走了就别回头了 2021-01-24 02:45

I\'m trying to write a program that simulates the terminal tab completion. But I\'m unsure of how to trap the tab key. This is a non gui application. I\'m not looking for swing/

相关标签:
1条回答
  • 2021-01-24 03:22

    After some googling, i found that there are quite a few java libraries for handling console input. Some of them are:

    1. jLine

    2. Lanterna

    3. Java Curses Library

    4. Charva

    5. Blacken

    jLine have features like custom keybinds, tab completion, line editing etc. jLine have method like readVirtualKey that reads a virtual key from the console e.g. VK_UP.

    You can also implement auto complete functionality using tab key. You might have to implement your own Completer class for that. Have a look at the link given below, it clearly shows tab completion functionality. May be that is what you need.

    https://jeszysblog.wordpress.com/2012/04/14/readline-style-command-line-editing-with-jline/

    0 讨论(0)
提交回复
热议问题