Tandy 1000 Basic Reference Manual page 179

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10 I
BASIC Keywords
INKEY$
Function
INKEY$
Reads a character in the keyboard buffer, and returns a 0-, 1-, or 2-
byte string. INKEY$ does not echo the character to the display.
0
A 0-byte (null) string indicates that no key is pressed.
0
A 1-byte string is a n actual character read from the keyboard.
0
A 2-byte string indicates that the key pressed is one of the special
keys that has an extended code. The first byte is hex 00. See Ap-
pendices B and
D
for a complete list of extended codes.
INKEY$ is invariably put inside some sort of loop. If not, pro-
gram execution passes through the line containing INKEY$ be-
fore you can press a key.
The [ C T R L I [ m ! and IHOLD] keys are not passed to INKEY$. Also
[ALT][CTRLI[],
which does a system reset, is not passed to
INKEY$.
Note: If your program contains an INKEY$ and you
press a function key, BASIC returns 1 character of the
key assignment a t a time. For example, suppose this
statement is executed:
A $
=
I N K E Y F
Now suppose you press
[,
which initially has the
value LIST. The first time the statement is executed
A$ equals
L,
the second time A$ equals I, and so on.
Keep this in mind when writing a BASIC routine t o
trap for a certain key. Your routine may not perform
as expected if you accidently press a function key.
You can assign the result of INKEY$ t o a string variable and
test the length of the string t o determine whether a 0-, 1-, or 2-
character string
is
returned by
INKEY$. Example:
1 0 A $ = I N K E Y $ :
I F
A $ = " "
T H E N 1 0
2 0 I F L E N ( A $ ) > l
T H E N P R I N T A S C ( M I D ( A $ , l , I ) ) ,
3 0 G O T 0 1 0
A S C ( M I D $ ( A $ , 2 , 1 ) )
E L S E P R I N T A S C C A $ )
Ex
ample
1 0 A $
=
I N K E Y S
2 0 I F A $
=
" I '
T H E N 1 0
causes the program to wait for you to press a key.
177

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents