# KeyHit

KeyHit (void);

## Purpose

Indicates whether the user pressed a key on the keyboard.

KeyHit returns 1 if a keystroke is available in the keyboard buffer and returns 0 otherwise. After a keystroke is available, call GetKey to flush the keyboard buffer. Otherwise, KeyHit continues to return 1.

| Note KeyHit detects keystrokes only in the Standard I/O window or the console window of a console application. The function does not detect keystrokes in windows you create with the User Interface Library. Linux KeyHit detects keystrokes only in the Standard I/O window. You must first call the SetStdioPort function to specify to use the Standard I/O window.

KeyHit brings the Standard Input/Output window to the front.

### Example

/* Flush any pending keystrokes. */
while (KeyHit())
GetKey();
/* Perform loop indefinitely until the user presses key. */ while (!KeyHit()) {
}

## Parameters

None.

## Return Value

Name | Type | Description
result | integer | Indicates if a key has been pressed.
Code | Description
0 | Key has not been pressed.
1 | Key has been pressed.