Page 1 of 1

Poll keyboard in "C"

Posted: Thu Nov 07, 2013 6:01 am
by jwzumwalt
I need to be able to poll the keyboard in "C" without interrupting the program.
How would I do this?

Re: Poll keyboard in "C"

Posted: Thu Nov 07, 2013 6:05 am
by AndyD
You could try something like this. I have been using something similar here.

Re: Poll keyboard in "C"

Posted: Thu Nov 07, 2013 6:15 am
by jwzumwalt
Thank you for your quick reply.

Any chance of you commenting the code you have on GIT?

Re: Poll keyboard in "C"

Posted: Thu Nov 07, 2013 6:19 am
by AndyD
jwzumwalt wrote:Any chance of you commenting the code you have on GIT?
Yes, there is a good chance. Probably wont happen until later tonight.

Re: Poll keyboard in "C"

Posted: Thu Nov 07, 2013 12:40 pm
by AndyD
jwzumwalt wrote:Any chance of you commenting the code you have on GIT?
OK I have commented the code in key.c and key.h.

Edit: Another option would be to use ncurses

Re: Poll keyboard in "C"

Posted: Thu Nov 07, 2013 5:22 pm
by jwzumwalt
Thanks for the comments.

I forgot about ncurses.
I have never used it but several programmers I worked with wrote many terminal programs with it 25yrs ago.
Your code looks short and simple, I'll give it a try first.