The keyboard matrix
The ACE's 67 keys are wired as an 8 × 8 grid. A microcontroller on the board — an ATmega1284P running the AB Controller firmware — drives one row at a time on PA0–PA7, reads the columns back on PB0–PB7, and hands the CPU the ASCII code for whatever it found.
You never need this to use the machine. You need it if you are building a keyboard for an enclosed ACE, chasing a key that has stopped working, or writing code that reads the ports directly.
Row down the left, column across the top. The small code under each key is what the controller sends when you press it.
PB0 | PB1 | PB2 | PB3 | PB4 | PB5 | PB6 | PB7 | |
|---|---|---|---|---|---|---|---|---|
PA0 | `$60 | 1$31 | 2$32 | 3$33 | 4$34 | 5$35 | 6$36 | 7$37 |
PA1 | 8$38 | 9$39 | 0$30 | -$2D | =$3D | Bksp$08 | Esc$1B | Tab$09 |
PA2 | Q$51 | W$57 | E$45 | R$52 | T$54 | Y$59 | U$55 | I$49 |
PA3 | O$4F | P$50 | [$5B | ]$5D | Backslash$5C | Ins$1A | Caps not sent | A$41 |
PA4 | S$53 | D$44 | F$46 | G$47 | H$48 | J$4A | K$4B | L$4C |
PA5 | ;$3B | '$27 | Enter$0D | Del$7F | Shift modifier | Z$5A | X$58 | C$43 |
PA6 | V$56 | B$42 | N$4E | M$4D | ,$2C | .$2E | /$2F | Up$1E |
PA7 | Ctrl modifier | Menu not sent | Alt not sent | Space$20 | Fn not sent | Left$1C | Down$1F | Right$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 all the others and then dropped: no character, no state. Caps Lock in particular is not a lock, because there is no case for it to switch. Their switches are in the grid all the same — see Scanning it yourself.
Ctrl sends a control code. Ctrl+A through Ctrl+Z send 1 to 26, so Ctrl+C is $03 — the break — and Ctrl+H is $08, the same as backspace. Ctrl+[ sends $1B, which is Esc.
The arrow keys send $1C to $1F. Nothing in BASIC listens for them. They are there for programs you write.
The header
The grid comes out of the board on a 1 × 16 pin header at 2 mm pitch: pins 1–8 are PA0–PA7, pins 9–16 are PB0–PB7. On a stock ACE the board's own 67 switches are soldered across it.
Anyone putting the board in a case leaves those switches unfitted and wires their own 8 × 8 grid here instead. Same rows, same columns, same codes — the firmware does not know the difference.
Why reading a joystick is fiddly
Those two ports are the same sixteen VIA lines the joysticks use. The controller is scanning them ten times a second, so a program that reads the port directly will catch the scan mid-sweep and get nonsense.
That is why the Kernal's joystick routines disable the encoder, wait for it to let go of the lines, read, and enable it again — and why doing it by hand needs the same KBDisable → read → KBEnable dance, with about 200 µs of settling in the middle. The keyboard and the sticks has the code.
Scanning it yourself
The same release is what lets you read the keyboard as switches rather than as characters. With both encoders disabled the sixteen lines are yours: drive one row low from GPIO_DDRA and GPIO_PORTA, read the eight columns back from GPIO_PORTB, and a 0 bit is a key held down at that intersection. Eight rows gets you the state of all 67 keys, Caps Lock, Menu, Alt and Fn included — the firmware's opinion about them stops at the ASCII it hands over, not at the wiring.
Give the ports back promptly, though. Nothing in flight is lost — a character is only consumed once it has been strobed across — but the controller cannot hand anything over while you hold them, and PS/2 keystrokes arrive regardless and stack up in a buffer sixteen deep. Its own sweep of the board's keys is suspended too, and it wants two clean sweeps 10 ms apart before it will call a key pressed, so the more of the time the ports are yours the longer ordinary typing takes to register.
The other thing to know is that there are no diodes in the grid, so three keys held in a rectangle put a phantom fourth at the free corner — fine for a modifier or two alongside a key, not a foundation for chords.
The keyboard and the sticks has the loop.
📄 Keyboard Matrix card — the grid on one printable page. See also the Keyboard Layout card for the physical arrangement.

