the following javaprogram reads any keypress without Enter and its output is the key and its asciivalue in brackets. as precaution jcurses has to be properly set up. ctrl-c or '#' ends the program. only the input is coded, a simple System.out.println serves as output. as processing of the values nearly anything can be imagined.
import jcurses.system.InputChar;
import jcurses.system.Toolkit;
public class readchar3 {
public static void main (String[] args)
{
String st;
char ch;
int i;
st = "";
ch = ' ';
i = 0;
while (true)
{
InputChar c = Toolkit.readCharacter();
ch = c.getCharacter();
i = (int) ch;
System.out.print ("you typed " + ch + "(" + i + ")\n\r");
// break on '#'
if (ch == '#') break;
}
System.out.println ("Programm wird beendet. Verarbeitung kann beginnen.");
}
}