2

i'm making a program without GUI, and i want catch the ESC key when is pressed for cancel a input (using Scanner).

I'm searching on google an here but i just found for SWING

Rafael Carrillo
  • 2,772
  • 9
  • 43
  • 64
  • 1
    Possible duplicate of: http://stackoverflow.com/questions/4005574/java-key-listener-in-commandline – Dan W Aug 30 '11 at 22:22
  • And I don't think is possible because cli applications don't have knowledge of what key code was pressed. I wonder what others will say. – Amir Raminfar Aug 30 '11 at 22:25
  • have a look at this post: http://stackoverflow.com/questions/7173674/simple-way-to-cancel-user-input-on-esc-key-pressed/7173807#7173807 – Heisenbug Aug 30 '11 at 22:34

1 Answers1

0

JLine may help. It is a third party library and has its own native code, but I don't think there's a way to read ESC from the console in java using standard API.

prunge
  • 22,460
  • 3
  • 73
  • 80