•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
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-FileINKEY$

INKEY$ reads a character from the keyboard. This function will, however, not
detect depressions of the Shift, Alternate, or Control keys alone. INKEY$ does
not wait for a key to be pressed, but scans the keyboard to check whether a key
has been pressed since the last scan. If it has, the command accepts that
pressed key, otherwise a null string ("") is returned. When the key pressed has
no ASCII code, for example a Function key or the HELP or UNDO keys, then INKEY$
returns the scan code of the pressed key as a two-character long string
containing CHR$(0) as its first character, and the identification code of the
special key as the second character.

The following example demonstrates how the values returned by INKEY$ can be
examined:

    DO
      t$=INKEY$
      IF t$<>""
        IF LEN(t$)=1
          PRINT "Character: ";t$,"ASCII code: ";ASC(t$)
        ELSE
          PRINT "CHR$(0)+Scan code: ";CVI(t$)
        ENDIF
      ENDIF
    LOOP

--> Displays the ASCII or Scan code of each key pressed.

Note: CVI() turns a 2-byte string into an integer. As the first byte of the
      string is zero, in this case it returns the value of the second byte.