I am not one for games, so I do not pay much attention to vintage controllers or gaming features on modern keyboards. But when I came upon this Atari CX85, it looked a bit more like an actual external keypad and I remembered something about them entering into a joint venture to make the key switches.The keys on this one have a W on them, which I conclude is Wong's.
The keypad plugged into the joystick port. The wiki has a comprehensive page on this interface.
The circuit inside couldn't be much simpler. The controller is a MM74C92x key encoder, like one would use with a phone keypad. This needs a couple capacitors for scan and debounce timing. And there is a 4049B high-voltage inverter, for the CMOS / TTL interface.
The key available signal goes to the trigger pin and the key number shows up in the joystick direction pins, plus one other.
Except for the key switch matrix itself, it's easy to recreate this circuit with stuff in the parts bin.
The PC end is more interesting. The 9-pin port has some signals programmable for input or output. But two of the inputs are meant to be connected to potentiometers and so have simple analog-to-digital circuits. The varying voltage charges a capacitor and a counter from the screen retrace times how long that takes. An interrupt handler for the trigger line can read the BPOT one-shot directly from a register, but this take a bit of time so a delay is needed. And this is where the fifth key number bit goes.
All these details are in the Field Service Manual and Technical Reference Notes.
The PC's own Hardware Manual explains how an older keypad, which plugged into the identical port, worked. Those had even less circuitry inside: just a key-pad matrix of metal dome switches and a couple resistors. The program had to do the scanning. This entails reading both of the POT signals and without a triggering event. So the sample code uses the counting register and compares against a conventional low value to tell whether a pressed key is grounding it through the current row.
I therefore kept an eye out at garage sales and thrift stores for keypads with a plasticy DE-9 and accumulated a couple in the same box as the CX85. The feel as bad as they look and they are only interesting in context.
There are a number of DE-9 joystick to USB converters on eBay for use with emulators. Since, like I said, I'm not actually interested in that, I just made it look like a keypad.
In honor of the original, I did, though, use AVR ports with ADCs for the analog signals, even though they are programmed as digital inputs. And the same hardware does both, though, right now, with separate firmware.
The older keyboard controllers are even easier to recreate, but limited to 4x3 because there are only 7 data signals.
The same pin layout for the joystick port was evidently followed by other controllers, such as Commodore for the C64 and VIC-20. The Cardco Cardkey is another more or less ordinary numeric keypad meant to plug into the joystick port.
It has a 4x4 Stackpole grid of switches. Some of the branding has rubbed off on this particular one, but that big blank area is actually there for a reason. There isn't any active controller inside, but there are 48 diodes.
These are arranged so that each key press grounds the trigger pin and a unique combination of the joystick direction pins. In other words, it's the same protcol as the CX85, limited to four columns, without debounce, and with even less support for key roll-over. So the same QMK matrix code works, just with a custom layout.