' demo use of the keypad scan
' a complete help of Annex32 can be found here
' https://cicciocb.com/annex32help/V1.442/
dim rows(4) = 26, 25, 33, 32
dim cols(4) = 35, 34, 39, 36
dim sym$(16) = "1", "2", "3", "A", "4", "5", "6", "B", "7", "8", "9", "C", "*", "0", "#", "D"
' set the pins as input and output
for z = 0 to 3
pin.mode rows(z), output
pin.mode cols(z), input, pulldown
pin(rows(z)) = 0
next z
maxscroll.setup 8, 21
maxscroll.print "Press Keys"
maxscroll.show 63, 5
k$ = ""
Kp$ = ""
line$ = space$(16)
do
scan k$
if (k$ <> kp$) and (k$ <> "") then
print k$
line$ = right$(line$ + k$, 10)
maxscroll.text line$
maxscroll.show 64, 5
end if
kp$ = k$
'pause 100
loop
sub scan(key$)
local r, c, l, code
code = -1
for r = 0 to 3
pin(rows(r)) = 1
for c = 0 to 3
l = pin(cols(c))
if (l=1) then
code = r*4 + c
exit for
end if
next c
pin(rows(r)) = 0
if (code <> -1) then exit for
next r
if (code <> -1) then key$ = sym$(code) else key$ = ""
end sub