TRS-80
MODEL
III
INKEY$
Returns
a one-character string determined by a keyboard check. The last key
pressed
before the check is returned. If no key has been pressed, a null string
(length zero) is returned. This is a
very
powerful function because it lets
you input
values while the
Computer is executing
—
without using the (ENTER) key. The
popular video
games which let you fire at will, guide a moving dot through a maze,
play tennis
, etc
.
, may all be simulated using the INKEYS function (plus a
lot of other
program
logic, of course).
Characters typed to an
INKEYS are not
automatically displayed
on the screen.
INKEYS is often placed
inside some sort of loop, so that the keyboard is scanned
repeatedly.
Example Program:
540
55t
C
3 5405 INKEY*:
GOTO
5*
RUN the program;
notice that the screen remains blank until the first time
you hit a
key
. The last key hit remains on the screen until you hit another one
. (The last key
hit
is always saved
.
The
INKEYS
function
uses
it until it is replaced
by
a
new value
.
)
INKEYS may be used in
sequences of loops to
allow
the user to build up a longer
string.
Example:
590 PRINT
"ENTER
THREE
CHARACTERS"
600 A*
=
INKEY*:
IF
A*
610 B*
=
INKEY*:
IF
B*
620 C*
=
INKEY*:
IF
C*
630 D*
=
A*
+
B*
+
C*
""
THEN
600
ELSE
PRINT
A*;
""
THEN
610
ELSE
PRINT
B*i
""
THEN
620
ELSE
PRINT
C*
;
A three-character string
D$ can now be entered via the keyboard without using
the
(ENTER) key.
NOTE:
The statement
IF A$
=
"
"
compares A$ to the null string.
There are no
spaces between
the double-quotes.
166