Quote:
Originally Posted by leonardo6023
Hello
I am using gcc 4.3.2
i was wondering how i would realize an up/down/left/right arrow key press in realtime during execution of my C program in the terminal.
Also, if it would be possible to realize the key stroke without emptying the input buffer using a /n or something of the sort.
Thanks
|
You'll need to use termio to set the tty into character mode instead of line mode. Then when you read(fd, &c, 1); you'll get the characters as they're pressed rather than when someone presses return. After that, it's a simple matter of handling the character codes you receive.