kbhit() Check Keyboard Input Buffer for Character Waiting
#include <conio.h>
int kbhit(void);
kbhit() checks to see if a key has been recently pressed. If it has,
the character is waiting in the input buffer and can be read using
getch() or getche().
Returns: Non-zero if a key has been pressed; otherwise 0.
Notes: If getch() or getche() is called to read a key, without
first calling kbhit() to see if a character is waiting in
the buffer, the program may pause until a key is pressed.
-------------------------------- Example ---------------------------------
The following statements check to see if a key has been pressed
before reading a character from the console.
#include <conio.h>
int keypress, ch;
main()
{
keypress = kbhit();
if (keypress != 0)
ch = getche();
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster