[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
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();
        }

See Also: getch() getche()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson