kbhit (msvcrt)
Last changed: neoscrib-67.168.110.227

.
Summary
Checks the console for keyboard input.

C# Signature:

[DllImport("msvcrt.dll", CallingConvention=CallingConvention.Cdecl)]
static extern int kbhit();

VB Signature:

<DllImport("msvcrt.dll", CallingConvention:=CallingConvention.Cdecl)> _
Shared Function kbhit Lib "msvcrt.dll" () As Integer
End Function

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

// Wait until the user presses a key.

while (!kbhit());

Alternative Managed API:

This is in the .NET 2.0 Console class functions System.Console.KeyAvailable() or System.Console.ReadKey().

System.Console.KeyAvailable() - Gets a value indicating whether a key press is available in the input stream. (Nonblocking)

System.Console.ReadKey() - Obtains the next character or function key pressed by the user. Allows for both echoing key to screen or not.

Documentation
kbhit on MSDN