Specifications
Commands - 61
KEYPAD$
Process Function
SYNTAX: a$=KEYPAD$(0)
a=KEYPAD$(1)
PURPOSE: To return a one–character string in response to a keypad input or return the position of the key.
REMARKS: KEYPAD$(0) returns a single–character string that has been assigned to a key. It is most useful on
16–key devices. If no key was pressed ,or if you read the keypad again before another key is pressed,
a null string is returned.
KEYPAD$(1) returns the key position. Keypads often have legends that are not single letters. Thus,
the first syntax may not make sense. If no key was pressed, or if you read the keypad again before
another key is pressed, a zero is returned.
A table in RAM can be programmed to return any ASCII value. The table is set up so that the first
character is in the upper–left–hand corner and the last character is in the lower–right–hand corner.
See SYS(8).
You can assign a single–character string to the keys in the following manner.
10 FOR X=0 TO 15
20 READ A$
30 POKE SYS(8)+X,ASC(A$)
40 NEXT
50 DATA 1,2,3,A,4,5,6,B,7,8,9,C,*,0,#,D
This example matches many 16 position keypads.
RELATED: ON KEYPAD$, INPUT KEYPAD$
EXAMPLES: The first example uses a 16–key keypad.
40 ON KEYPAD$ GOSUB..Key_interrupt
50 GOTO 50
60 ..Key_interrupt
70 PRINT KEYPAD$(0)
80 RETURN
ERROR: none