Hi,
I want to get keyboard character when pressed. I have the following code (and i've tried many others...). But the character is only recieved when pressed CR. How can I instantly get the character when it is pressed?
thanks in advance
Indy
char getCommand(void)
{
int hDevice;
char key[1];
char command = 0;
hDevice = open("/dev/pts/0", O_RDONLY | O_NONBLOCK);
if(read(hDevice, key, 1) == -1)
command = 0;
else
command = key[0];
return command;
}
I want to get keyboard character when pressed. I have the following code (and i've tried many others...). But the character is only recieved when pressed CR. How can I instantly get the character when it is pressed?
thanks in advance
Indy
char getCommand(void)
{
int hDevice;
char key[1];
char command = 0;
hDevice = open("/dev/pts/0", O_RDONLY | O_NONBLOCK);
if(read(hDevice, key, 1) == -1)
command = 0;
else
command = key[0];
return command;
}