The keyboard is scanned much like a PC keyboard, in columns and rows, forming a grid (well, mostly). The process to read the keyboard is to select a column (called a "group"), then you can read the status of all the keys in that column. Repeat for other columns as you want. This port merely returns which keys are depressed or not depressed at the instant.
Before each output to the port, the reset command must be sent. It is 0FFh. The sequence of outputting: Reset command, group number. The port may then be read for status information.
At the end of this document the equates for the 7 groups are listed, as well as the values for the keys in those groups.
Example:
ld a,0FFh
out (1),a
nop \ nop ;You must delay so the hardware has time to respond
ld a,Group1
out (1),a ;set group
nop \ nop
in a,(1) ;read the status
Each key in a group is a bit of the input from the port. The bit will be 0 if that corresponding key is pressed. Note that if you output 00h as the group, then you can scan the entire keypad. In that case you can't isolate specific keys though, only detect that some key was pressed.
Group1 .equ 0feh
KDown .equ 254
KLeft .equ 253
KRight .equ 251
KUp .equ 247
Group2 .equ 0fdh
KEnter .equ 254
KPlus .equ 253
KMinus .equ 251
KMul .equ 247
KDiv .equ 239
KPower .equ 223
KClear .equ 191
Group3 .equ 0fbh
kMinus2 .equ 254
kThree .equ 253
kSix .equ 251
kNine .equ 247
kRbracket .equ 239
kTan .equ 223
kVars .equ 191
Group4 .equ 0f7h
KPoint .equ 254
KTwo .equ 253
KFive .equ 251
KEight .equ 247
KLbracket .equ 239
KCos .equ 223
KPrgm .equ 191
KStat .equ 127
Group5 .equ 0efh
KZero .equ 254
KOne .equ 253
KFour .equ 251
KSeven .equ 247
KComma .equ 239
KSin .equ 223
KApps .equ 191
KGraphvar .equ 127
Group6 .equ 0dfh
KSto .equ 253
KLn .equ 251
KLog .equ 247
kX2 .equ 239
kX-1 .equ 223
kMath .equ 191
kAlpha .equ 127
Group7 .equ 0bfh
KGraph .equ 254
KTrace .equ 253
KZoom .equ 251
KWindow .equ 247
KY .equ 239
k2nd .equ 223
kMode .equ 191
kDel .equ 127