kbhit

From RAD Studio
Jump to: navigation, search

Go Up to conio.h Index

Header File

conio.h

Category

Console I/O Routines

Prototype

int kbhit(void);

Description

Checks for currently available keystrokes.

kbhit checks to see if a keystroke is currently available. Any available keystrokes can be retrieved with getch or getche.

Note: Do not use this function in Win32 GUI applications.

Return Value

If a keystroke is available, kbhit returns a nonzero value. Otherwise, it returns 0.

Example

#include <conio.h>
int main(void)
{
 cprintf("Press any key to continue:");
    while (!kbhit()) /* do nothing */ ;
    cprintf("\r\nA key was pressed...\r\n");
    return 0;
}
 

Portability

POSIX Win32 ANSI C ANSI C++

+