The Editors and
Readers of COMPUTE!
Reading Apple Keys
I have just read Apple SpeedCalc
in COMPUTE!'s February 1986 issue and noticed that the program's
commands use the Open Apple and Closed Apple keys. How do you read
those keys? They don't show up in INPUT statements or when the keyboard
is read. Can I access them from BASIC or only from machine language?
David Reed
The Open Apple and Closed Apple keys, which appear only on Apple IIe and IIc computers, are easy to read from BASIC or machine language. Both can be read in BASIC by PEEKing certain memory locations. The value in location 49249 ($C061) is 128 or greater if the Open Apple key is pressed, and less than 128 if it is not. Location 49250 ($C062) gives the same information for the Closed Apple key. Here's a program fragment that gets a keypress and also checks these two special keys:
100 GET K$:REM WAIT FOR A
KEYPRESS
110 OA = PEEK(49249):CA =
PEEK(49250)
120 IF K$ ="a" AND OA>= 128 AND
CA<128 THEN GOSUB 1000
These statements call a subroutine at line 1000 if Open Apple-A is pressed, but not if Open Apple-Closed Apple-A is pressed.