Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ kbhit(DOS) — OpenDesktop Software Development System 1.0.0d

Media Vault

Software Library

Restoration Projects

Artifacts Sought

     Name
          kbhit - Checks for a keystroke.

     Syntax
          #include <conio.h>

          int kbhit(void)

     Description
          The kbhit function checks the console for a recent
          keystroke.

     Return Value
          The kbhit function returns a nonzero value if a key has been
          pressed. Otherwise, it returns 0.

     Example
          #include <conio.h>

          main()
           {
                  printf( "waiting...\n" );

                  /* Loop until kbhit() reports a keystroke: */
                  while( !kbhit() );

                  printf( "key struck was '%c'\n", getch() );
           }

          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 fetch the keystroke. If
          the program calls either function without first checking
          kbhit, the program may pause while waiting for input.

                                                (printed 6/18/89)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026