Bit of an odd one here but i'm lloking for a way to check if NO key is being pressed. I know I can use getch() to get a key press but this is stumping me.
I would normally use kbhit(), but this is in the conio.h which isn't included?
I presume you are using Serial or USB Serial. If so, try using readable(). It returns 1 if there is a character available to read, otherwise it returns 0. The Handbook PC Serial page contains an example.
Thanks for your reply. I am using a standard UK keyboard. I have solved the problem.
To keep the story short I kept getting a character appear on the screen when I didn't want it to. Thought I could sort it by checking there were no character waiting to be written, it didn't work.
Finally solved it by using fflush(connection) to wipe the buffer.
Thanks for your help guys.
Martin
Important Information for this Arm website
This site uses cookies to store information on your computer.
By continuing to use our site, you consent to our cookies.
If you are not happy with the use of these cookies, please review our
Cookie Policy
to learn how they can be disabled.
By disabling cookies, some features of the site will not work.
Access Warning
You do not have the correct permissions to perform this operation.
Hi everyone,
Bit of an odd one here but i'm lloking for a way to check if NO key is being pressed. I know I can use getch() to get a key press but this is stumping me.
I would normally use kbhit(), but this is in the conio.h which isn't included?
Thanks in advance
Martin