Keyboard Matrix

A.C. Wright 6502
ACE · AB Controller
Rows and columns
The ACE's 67 keys are wired as an 8 × 8 grid. The AB Controller drives one row at a time on PA0PA7 and reads the columns back on PB0PB7. Find your key, read off its row and column, and the small number is the ASCII code the controller sends when you press it.
PB0PB1PB2PB3 PB4PB5PB6PB7
PA0 `$601$312$323$33 4$345$356$367$37
PA1 8$389$390$30-$2D =$3DBKSP$08ESC$1BTAB$09
PA2 Q$51W$57E$45R$52 T$54Y$59U$55I$49
PA3 O$4FP$50[$5B]$5D \$5CINS$1ACAPSignoredA$41
PA4 S$53D$44F$46G$47 H$48J$4AK$4BL$4C
PA5 ;$3B'$27ENTER$0DDEL$7F SHIFTmodifierZ$5AX$58C$43
PA6 V$56B$42N$4EM$4D ,$2C.$2E/$2FUP$1E
PA7 CTRLmodifierMENUignoredALTignoredSPACE$20 FNignoredLEFT$1CDOWN$1FRIGHT$1D
What the controller does with a press
Letters are always capitals. Shift changes the symbols and the number row and nothing else — there is no lower case at the machine. It exists over the serial line, and only there.
Four keys send nothing. Caps Lock, Menu, Alt and Fn are scanned like every other key and then dropped: no character, no state. Caps Lock in particular is not a lock, because there is no case for it to switch. The switches are in the grid all the same — see below.
Ctrl sends a control code. Ctrl+A through Ctrl+Z send 1 to 26, so Ctrl+C is $03 (break) and Ctrl+H is $08 (backspace). Ctrl+[ sends $1B, the same code as Esc.
Esc stops a running program. BASIC checks for it between statements. It is the key to reach for when something runs away; the reset button above it is the one for when even that does not answer.
Where the grid comes out of the board
The matrix is on the ACE's KEYBOARD header — a 1 × 16 pin header at 2.00 mm pitch, PA0PA7 on pins 1–8 and PB0PB7 on pins 9–16. On a stock ACE the board's own switches are soldered across it. Anyone enclosing the board leaves those unfitted and wires an outboard keyboard here instead — same grid, same codes.
The same two VIA ports carry the joysticks. That is why the Kernal disables the encoder before a raw read and enables it again afterwards, and why reading a stick by hand needs the KBDisable → read → KBEnable dance.
Scanning it yourself. With the encoders released the sixteen lines are yours: drive one row low through GPIO_DDRA / GPIO_PORTA, read the columns on GPIO_PORTB, and a 0 bit is a key held at that intersection. Eight rows gets all 67 keys as switches, the four ignored ones included. Give the ports back promptly — the controller cannot hand a character over while you hold them, and is not scanning the board's own keys either — and remember there are no diodes: three keys in a rectangle report a phantom fourth.