Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>kbhit() check keyboard input buffer for character waiting</b> http://www.X-Hacker.org [<<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()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson