Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I detect arrow keys in java console not in GUI? [duplicate]

Tags:

java

I'm writing an application and I need to detect arrow keys inside it. C++ has the getch() function. We want to take the input and then add a check on ASCII values.

How can we detect input arrow keys? Thanks

like image 225
Zeeshan Chaudhry Avatar asked Mar 03 '12 10:03

Zeeshan Chaudhry


1 Answers

I have written a Java class RawConsoleInput that uses JNA to call operating system functions of Windows and Unix. It can be used to read the arrow keys, but the character codes are different on Windows and Unix.

like image 81
Christian d'Heureuse Avatar answered Sep 24 '22 05:09

Christian d'Heureuse