I
Ivan_G_S
hello, community!
i am trying to read single characters and keystrokes with a java
console application using linux terminals (konsole, xterm).
int inputChar = 0;
while ((inputChar = System.in.read()) != -1) {
char input = (char) inputChar;
System.out.print(" <" + input + "> ");
System.out.flush();
}
but instead of getting one keystroke after another, i get them all at
once after pressing return.
furthermore, control characters, instead of being processed, are
displayed this way
^[[A^[[B^[[D^[[C^[
after pressing return, only [ appears.
( arrows: up, down, left, right; esc. )
is there a possibility to do this correctly at all using java?
or do i have to write a GUI application to handle keystrokes?
thanks in advice!
i am trying to read single characters and keystrokes with a java
console application using linux terminals (konsole, xterm).
int inputChar = 0;
while ((inputChar = System.in.read()) != -1) {
char input = (char) inputChar;
System.out.print(" <" + input + "> ");
System.out.flush();
}
but instead of getting one keystroke after another, i get them all at
once after pressing return.
furthermore, control characters, instead of being processed, are
displayed this way
^[[A^[[B^[[D^[[C^[
after pressing return, only [ appears.
( arrows: up, down, left, right; esc. )
is there a possibility to do this correctly at all using java?
or do i have to write a GUI application to handle keystrokes?
thanks in advice!