inkey$ - read from the keyboard without blocking
is used to read data from the keyboard on a character by character basis.
The data is not echoed back, i.e., it is not displayed on the screen.
The returned value is a zero-, one-, or two-character string indicating
no character pending, an actual character being read, or an extended code,
If characters are present in the keyboard buffer,
leaves undisturbed any characters trailing the character or
extended escape sequence that it reads.
For certain keys or key combinations that cannot be represented in
standard ASCII code, an extended code is returned by the
If a two-character string is received by
then the first character returned will be the null character and
the second code will be among the following:
| || ||CODE|| ||KEY NAME|
| 3||Null character|
|58-68||Function keys, F0-F10|
|79||End (or Home down)|
The following program will await user input before stopping.
10 n = 0
20 n = n + 1
30 print "Type 'x' to stop this program"
40 print n;
50 a$ = inkey$ : if a$ = "x" then stop
60 goto 20
Line 50 shows the use of
When the user finally types x,
the program terminates.
that the character is not echoed to the display (as with
If the environment variable BASECHO is set to a non-null value
when a Basmark QuickBASIC program begins executing,
the BASIC input/output facility operates differently in order
to support half-duplex terminals such as the IBM 3278.
In this modified behavior of the input/output facility, the terminal
modes are not altered, so that the usual erase and kill processing
and echoing of terminal input are performed.
In the specific case of
input is blocking and line-oriented,
and it is always the case that a string containing exactly
one character is returned.
If a character is already available in the keyboard buffer when
that character is returned.
will not return until a complete line of input is typed.
As an illustration,
the program in the example above will behave differently if BASECHO is set when
the program is executed: the messages in lines 30 and 40 will each be printed
once, and the program will block at line 50 awaiting a line of
After a line of input has been entered,
the call to
For each character of input preceding x, the character will be echoed
and one circuit of the loop will
occur causing the messages in lines 30 and 40 to each be printed once.
The program will terminate when it reads the input character x, but will
leave unread any characters following the x, including the terminating
The Basmark QuickBASIC Programmerís Manual