How to Flush the Keyboard Typeahead Buffer (43993)
The information in this article applies to:
- Microsoft C for OS/2 5.1
- Microsoft C for OS/2 6.0
- Microsoft C for OS/2 6.0a
- Microsoft C/C++ for MS-DOS 7.0
- Microsoft Visual C++ 1.0
- Microsoft Visual C++ 1.5
- Microsoft C for MS-DOS 5.1
- Microsoft C for MS-DOS 6.0
- Microsoft C for MS-DOS 6.0a
- Microsoft C for MS-DOS 6.0ax
This article was previously published under Q43993 SUMMARY
To flush the BIOS keyboard typeahead buffer, the MS-DOS Interrupt 21
Function 0CH may be used. This function clears the keyboard typeahead
buffer and then invokes a reading function specified in the AL
register. The AL register can be 0x01, 0x06, 0x07, 0x08, or 0x0A to
specify a valid reading function. If you do not intend to read after
flushing the buffer, you may specify an invalid number in AL.
Another method of flushing the BIOS buffer is to call the console I/O
function getch() until the function kbhit() becomes false. This method
is demonstrated in the program below and has the advantage of being
usable under OS/2 as well as MS-DOS.
Modification Type: | Major | Last Reviewed: | 12/1/2003 |
---|
Keywords: | kb16bitonly KB43993 |
---|
|