Topic : The GFA-Basic Compendium Author : GFA Systemtechnik GmbH Version : GFABasic.HYP v2.98 (12/31/2023) Subject : Documentation/Programming Nodes : 899 Index Size : 28056 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : @default : Document not found @help : Help @options : +g -i -s +z @width : 75 @hostname : STRNGSRV @hostname : CAB @hostname : HIGHWIRE @hostname : THING View Ref-FileKEYTEST n KEYGET n KEYLOOK n n: ivar KEYTEST is similar to INKEY$ and reads a character from the keyboard. If no key was pressed since the last input (apart from Alternate, Control, Shift, and Caps Lock) the returned value is zero, otherwise its value corresponds to the key in the table shown below for KEYGET. KEYGET waits for a key to be pressed and then returns a long word value corresponding to the key. This 32-bit long word is constructed as follows: Bits 0- 7: ASCII code Bits 8-15: Zero Bits 16-23: Scan code Bits 24-31: Status of Shift, Control, Alternate, and CapsLock as follows: Bit Key 0 Right shift 1 Left shift 2 Control 3 Alternate 4 Caps lock KEYLOOK allows a character to be read from the keyboard buffer, without changing the buffers contents, as with KEYGET or INKEY$. If n is a byte or word variable then an integer conversion takes place automatically. Examples: PRINT "Please press ESCape" REPEAT !The program runs through the loop UNTIL INKEY$=CHR$(27) !until the ESCape key is pressed. ' PRINT "Please press ESCaPe again" REPEAT !Again runs through the loop but KEYTEST n| !this time checks the keyboard here for UNTIL n|=27 !character number 27. --> Waits twice for the ESCape key to be pressed. Note that in the second example bits 0 to 7 are masked off automatically by using a byte-sized (8-bit) variable. PRINT "Please press a key" key_1|=INP(2) !Waits for a key-press. PRINT "Press another key please" KEYGET key_2| !Waits again. PRINT "INP(2): ";key_1| !The ASCII codes of the depressed PRINT "KEYGET: ";key_2| !keys are printed. --> Waits twice for keys to be pressed, and displays their ASCII codes. REPEAT KEYLOOK n% UNTIL n% INPUT "Type in something ";a$ --> Waits in a loop until a key is pressed, then begins the input of a$ without losing the initial character. DO KEYGET a% PRINT HEX$(a%,8),BIN$(a%,32), OUT 5,a% PRINT LOOP --> Waits for a key to be pressed and displays the value returned by KEYGET in both hexadecimal and binary. Note: OUT 5,a% allows the characters associated with control codes 0-32 to be displayed. Cnecin()+ Iorec()+