Condividi tramite


_kbhit

Controlla la console per l'input della tastiera.

Nota importanteImportante

Questa API non può essere utilizzata nelle applicazioni che vengono eseguite in Windows Runtime.Per ulteriori informazioni, vedere Funzioni CRT non supportate con /ZW.

int _kbhit( void );

Valore restituito

_kbhit restituisce un valore diverso da zero se una chiave raggiunta.In caso contrario, restituisce 0.

Note

La funzione del _kbhit della console per una sequenza di tasti recente.Se la funzione restituisce un valore diverso da zero, una sequenza di tasti è in attesa nel buffer.Il programma può quindi chiamare _getch o _getche per ottenere la sequenza di tasti.

Requisiti

Routine

Intestazione obbligatoria

_kbhit

<conio.h>

Per ulteriori informazioni sulla compatibilità, vedere Compatibilità nell'introduzione.

Librerie

Tutte le versioni delle Librerie di runtime C.

Esempio

// 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() );
}

Esempio di output

Hit me!! Hit me!! Hit me!! Hit me!! Hit me!! Hit me!! Hit me!!
Key struck was 'q' 

Vedere anche

Riferimenti

Console e porta I/O