NAME

inkey$ - read from the keyboard without blocking

SYNOPSIS

v$ = inkey$

DESCRIPTION

Inkey$ is used to read data from the keyboard on a character by character basis.  The data is not echoed back, i.e., it is not displayed on the screen.  The returned value is a zero-, one-, or two-character string indicating no character pending, an actual character being read, or an extended code, respectively.  If characters are present in the keyboard buffer, inkey leaves undisturbed any characters trailing the character or extended escape sequence that it reads.  For certain keys or key combinations that cannot be represented in standard ASCII code, an extended code is returned by the inkey$ function.  If a two-character string is received by inkey$, then the first character returned will be the null character and the second code will be among the following:

            CODE      KEY NAME
 
  3Null character
58-68Function keys, F0-F10
71Home
72Cursor up
73Page up
75Cursor left
77Cursor right
79End (or Home down)
80Cursor down
81Page down
82Insert
83Delete

EXAMPLE

The following program will await user input before stopping. 
	10 n = 0
	20 n = n + 1
	30 print "Type 'x' to stop this program"
	40 print n;
	50 a$ = inkey$ : if a$ = "x" then stop
	60 goto 20
Line 50 shows the use of inkey$.  When the user finally types x, the program terminates.  Notice that the character is not echoed to the display (as with input). 

SEE ALSO

input, input$

USAGE NOTES

If the environment variable BASECHO is set to a non-null value when a Basmark QuickBASIC program begins executing, the BASIC input/output facility operates differently in order to support half-duplex terminals such as the IBM 3278.  In this modified behavior of the input/output facility, the terminal modes are not altered, so that the usual erase and kill processing and echoing of terminal input are performed.  In the specific case of inkey$, input is blocking and line-oriented, and it is always the case that a string containing exactly one character is returned.  If a character is already available in the keyboard buffer when inkey$ is executed, that character is returned.  Otherwise, inkey$ will not return until a complete line of input is typed. 

As an illustration, the program in the example above will behave differently if BASECHO is set when the program is executed: the messages in lines 30 and 40 will each be printed once, and the program will block at line 50 awaiting a line of input.  After a line of input has been entered, the call to inkey$ will unblock.  For each character of input preceding x, the character will be echoed and one circuit of the loop will occur causing the messages in lines 30 and 40 to each be printed once.  The program will terminate when it reads the input character x, but will leave unread any characters following the x, including the terminating newline character. 

from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber