Skip to content

INKEY$

Syntax

INKEY$

Description

Returns either a one-character string containing a character read from the terminal or a null string if no character is pending at the terminal. No characters will be echoed and all characters are passed through to the program.

Note: Control-C behavior varied in original implementations. In MBASIC 5.21 interpreter mode, Control-C would terminate the program. This implementation passes Control-C through (CHR$(3)) for program detection and handling, allowing programs to detect and handle it explicitly.

Example

1000 REM TIMED INPUT SUBROUTINE
1010 RESPONSE$=""
1020 FOR I%=1 TO TIMELIMIT%
1030 A$=INKEY$ : IF LEN(A$)=0 THEN 1060
1040 IF ASC(A$)=13 THEN TIMEOUT%=0 : RETURN
1050 RESPONSE$=RESPONSE$+A$
1060 NEXT I%
1070 TIMEOUT%=1 : RETURN

See Also

  • FRE - Arguments to FRE are dummy arguments
  • HELP SET - Display help for a specific setting
  • INP - Returns the byte read from port I
  • LIMITS - Display resource usage and interpreter limits
  • NULL - To set the number of nulls to be printed at the end of each line
  • PEEK - Returns the byte (decimal integer in the range 0 to 255) read from memory location I
  • RANDOMIZE - To reseed the random number generator
  • REM - To allow explanatory remarks to be inserted in a program
  • SET (setting) - Configure interpreter settings at runtime
  • SHOW SETTINGS - Display current interpreter settings
  • TRON/TROFF - To trace the execution of program statements
  • USR - Calls the user's assembly language subroutine with the argument X
  • VARPTR - Returns the memory address of a variable
  • WIDTH - To set the printed line width in number of characters for the terminal or line printer