[1] Inputs a character from the keyboard, then echoes it to the display. If no character is ready, waits until one is available.
[2.0+] Reads a character from the standard input device and echoes it to the standard output device. If no character is ready, waits until one is available. Input can be redirected. (If input has been redirected, there is no way to detect EOF.)
Call with:
AH = 01H
Returns:
AL = 8-bit input data
Notes:
If the standard input is not redirected, and the character read is a Ctrl-C, an Int 23H is executed. If the standard input is redirected, a Ctrl-C is detected at the console, and BREAK is ON, an Int 23H is executed.
To read extended ASCII codes (such as the special function keys F1 to F10) on the IBM PC and compatibles, you must call this function twice. The first call returns the value 00H to signal the presence of an extended code.
See also Int 21H Functions 06H, 07H, and 08H, which provide character input with various combinations of echo and/or Ctrl-C sensing.
[2.0+] You can also read the keyboard by issuing a read (Int 21H Function 3FH) using the predefined handle for the standard input (0000H), if input has not been redirected, or a handle obtained by opening the logical device CON.
Example:
Read one character from the keyboard into register AL, echo it to the display, and store it in the variable char.
char db 0 ; input character
.
.
.
mov ah,1 ; function number
int 21h ; transfer to MS-DOS
mov char,al ; save character
.
.
.