2983 (fingeruebung)

this is the windows-thang for a keypress-read without enter. output char and ascii-value. loop terminated by ‘#’.

//offensichtlich ein windowsding
#include<stdio.h>//standardinout
//windows for kbhit and getchar
#include<conio.h>
//for sleep
#include<windows.h>
//linux
//#include <termios.h>
//#include <string.h>
int main() {

int countdown;
char ch;
int wert;
char b;
do {
	while(countdown++ <= 1000)
	{  
    		if(b=kbhit())            
        	break;             
    		Sleep(1);   
	}
	ch = getch();
	wert = ch;
	if (b != 0)        
    		{ printf("key %c ascii %d\n", ch, wert);}
} while (ch != '#');
printf ("programmende\n");
return 0;
}

some keys

#

#


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.”);
}
}
—-
https://www.minds.com/blog/view/487276494029070336/some-keys
https://minds.com/ewing