I did such interface long time ago. It was(is) an internal interface designed to fit in a place near the right side of the board when using the Plus case.
Technical details here:
This is the board
Designed to fit here:
Schematic. Very simple. One microcontroller does all the work.
Upon booting, the uC resets the keyboard and checks for scan 3 capability. If it's not present, then default to scan 2 mode. After then, the uC sends a command to the keyboard to leave the NumLock led on. That means that the keyboard is ready to use.
Features new in the firmware version (v1.3b) or changed from previous releases:
- Spanish and US-english keyboards supported (download and install the relevant update for your keyboard)
- All the Spectrum keystrokes are supported, even those that needs to switch to E-Mode for a while (Velesoft request).
- The Tab key has changed: now it maps to CAPS SHIFT+8, to help identing while working in GENS 3. Shift+Tab maps to CAPS SHIFT+5.
- Trigger key on Sinclair mode has changed to the left Alt key. The "0" key can also be used.
- The "Application" key toggles E-MODE on/off.
- The pound sign has been mapped to the key that shows the grave accent (both symbols have the same ASCII code).
- Spanish keyboard: the Ã‡ key is mapped to the (C) sign.
- Macros are stored in flash. They are not erased when the computer turns off. A update procedure doesn't erase the current stored macros.
- HOME and END keys also work as Begin Macro Recording (F3), and End Macro Recording (F4).
- The PAUSE key pauses a macro recording, so a key typed after PAUSE is not recorded. Recording is resumed pressing PAUSE again. While in macro playback mode, the PAUSE key toggles current macro playing on/off.
- Phantom keys appearing while the user types another key, or key combination does not happen anymore (hopefully). This was causes by the old way to give keytrokes to the ULA. From version 1.3, this method has radically changed. Now, the microcontroller polls the Z80A for IO requests to the ULA port. If there's a IO read request, the microcontroller answer it with theright value. For this reason, a hardware change is needed for the PS/2 adapter, internal version, to work correctly with the newer firmware versions.
- A little issue with Ctrl-Alt-Del not working correctly on powerup has been fixed.
Features present in the firmware version (v1.2):
- All alphanumeric keys are mapped to the Spectrum, as well as symbol keys and their shifter forms.
- Shifted alphabetic keys give the upper case version, as expected. Shifted numbers give the corresponding symbol.
- Current keyboard mapping is for the spanish standard 101/102-keys layout keyboard.
- Cursor block maps to the Spectrum cursor keys (i.e. "down" key is mapped to CAPS SHIF+6)
- ESC is mapped to the BREAK Spectrum key (CAPS SHIFT+SPACE)
- Caps Lock key is mapped to CAPS SHIFT + 2
- AltGr key maps to CAPS SHIFT + 9
- The F2 key (which is used mainly to edit the current filename in Windows Explorer and some other applications) maps to the EDIT key (CAPS SHIFT + 1).
- The Tab key maps to the EXTMODE key (CAPS SHIFT + SYMBOL SHIFT).
- The Backspace key is mapped to DELETE key (CAPS SHIFT + 0).
- Left Control key is mapped to CAPS SHIFT, and right Control key, to SYMBOL SHIFT.
- The separate numeric block behaves as if NumLock were always on (in fact, it is).
- The ScrollLock key toggles the cursor key mapping between normal use (editing mode) and Sinclair joystick mode. The later is signaled with ScrollLock led on. In Sinclair joystick mode, cursor keys are mapped to the same keys used by the Sinclair port 2 joystick (6,7,8, and 9). Trigger (0 key) is mapped to both Control keys (recalling the standard MAME layout for controls).
- If the reset pin is connected from the keyboard adapter PCB to the Spectrum, everytime the user presses Crtl-Alt-Del, a low pulse is sent to the reset pin at the Z80, hence enabling the user to reset the machine with the classic three-finger-salute.
The adapter has a bult-in mechanism for helping the user to diagnose a malfunction. Upon booting, if Alt+F12 is pressed, a series of keys are "typed-in" automatically. Assuming the K-mode, the sequence typed is:
There's another, more sophisticated, built-in test, designed to test the compatibility of a specific keyboard. Some of them doesn't allow more than a number of keys being pressed at the same time, or even more than one. This is very important, for example if you want to use the Sinclair joystick mode feature and want to press UP+RIGHT for instance. The test is entered by pressing Alt+F1. Prior to do this, it's better to reset the Spectrum.
Starting with firmware version 1.1, there is a macro feature, which can be considered in beta state. The user can record up to 6 macros of 512 key strokes each one (a key depressed and released counts as two key strokes).
- F3 enters macro recording. After F3, the user has to press the F-key he wants to assign to the macro. Then, CapsLock led goes on, signaling that a macro is being recorded.
- From this moment, the user can type anything he wants. If he reaches the keystroke limit, the recording is automatically ended.
- To stop a macro recording, press F4. CapsLock led goes off.
- To play the macro, simply press the F-key assigned to it. Caps Lock led goes on to signal macro play. A macro cannot be stopped unless Ctrl-Alt-Del is pressed. If the user resets the Spectrum using the lateral switch, macro playing won't stop.