Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mcnc!ecsvax!mjg From: mjg@ecsvax.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: How do you flush the PC's keyboard? Message-ID: <3312@ecsvax.UUCP> Date: Tue, 2-Jun-87 11:22:16 EDT Article-I.D.: ecsvax.3312 Posted: Tue Jun 2 11:22:16 1987 Date-Received: Thu, 4-Jun-87 05:20:11 EDT References: <747@thumper.UUCP> Organization: UNC Educational Computing Service Lines: 42 Summary: This is how I do it - any better ideas anyone ? In article <747@thumper.UUCP>, tr@thumper.UUCP writes: > According to _Advanced MS-DOS_ by Ray Duncan, DOS function C (hex) > resets the input buffer and then gets a character for input using one > of five DOS functions. They are 1, 6, 7, 8, and A (hex). I want to > flush the keyboard without getting input. The reason for this is that > the next thing my program does is call up a canned function that uses > keyboard input. > Here is one way to clear the typahead buffer that I am using successfully in one of my programs. Since the buffer has been flushed there will not be anything there but I call function 06 anyway as you MUST specify one of the functions 1,6,7,8 or A anyway. By using 6 it just checks the buffer which is empty and returns immediately without waiting. If by some remote chance a key has been pressed in the split second etween flushing the buffer and returning then it will be discarded. by the 06 calls. ---------------------------------------------------- ; Clear typeahead buffer routine ; uses flush buffer call, which must specify ; a keyboard command to follow. This method uses ; the int 21h call # 06 which reads the keyboard ; but does not wait for a character ctahed proc near mov ah,0ch ;flush keyboard buffer mov al,06 ;function forces a read mov dl,0ffh ;int 21, 06 afterwards. int 21h jz nochar ; or al,al ;if extended char was typed jz nochar ;get rid if it by another mov al,6 ;read mov dl,0ffh int 21h nochar: ret ctahed endp ---------------------------------------------------- ......decvax!mcnc!ecsvax!mjg