_kbhit
Visual Studio 2008
Checks the console for keyboard input.
int _kbhit( void );
Routine | Required header |
|---|---|
_kbhit | <conio.h> |
For more compatibility information, see Compatibility in the Introduction.
Libraries
All versions of the C run-time libraries.
// crt_kbhit.c
// compile with: /c
/* This program loops until the user
* presses a key. If _kbhit returns nonzero, a
* keystroke is waiting in the buffer. The program
* can call _getch or _getche to get the keystroke.
*/
#include <conio.h>
#include <stdio.h>
int main( void )
{
/* Display message until key is pressed. */
while( !_kbhit() )
_cputs( "Hit me!! " );
/* Use _getch to throw key away. */
printf( "\nKey struck was '%c'\n", _getch() );
}