Encoding and output
When a key on a keyboard is pressed, the equipment to which the keyboard is attached needs to know the identity of that key. Thus, some means is required to uniquely identify each key and provide its numeric code. This code may be an arbitrary number (such as model-specific or protocol-specific scancode) or it may be an externally-specified number such as the ASCII code for the key.
There have been numerous solutions to this requirement over the decades. Since the 1980s, this task has commonly been performed by a microcontroller within the keyboard, either on the same PCB as the switches, or on a separate board (the latter being always the case with membrane keyboards). Microprocessors were introduced between 1969 and 1971, so keyboards designed prior to this date could not take advantage of them. Instead, wiring or logic circuitry within the keyboard or within the switches themselves served this function.
At least two manufacturers designed self-encoding switches (referred to as “encoding” or “coding” switches). These are switches that directly output the binary code of the character they represent. As a result, all the switches within such a keyboard sit on a common bus at least eight bits wide: one VCC line to power all the switches, and seven output lines to receive the output bits, such as the ASCII codes of each switch. The switches are supplied by the manufacturer unconfigured, and they are each set to their appropriate code when the keyboard is assembled. This takes the form of clipping or bending terminals, or fitting interconnecting pieces between the switch and each bus line.
The earliest known type is Micro Switch KB, introduced in 1966. These provided 8-bit output. Around 1969, Mechanical Enterprises introduced an encoding keyboard switch model within their Mercutronic family. These provided ten output bits (eleven in the patent), and were solderless, using conductive lines on the back of adhesive tape to form the bus. The diagram below is based on the Mercutronic design, simplified to 7-bit output:
This approach has a major advantage in that no logic circuitry is needed to identify each key. However, there is also a disadvantage of using a common bus, as rollover is not possible: pressing two more keys simultaneously will jam the bus. Thus, a method is required to determine when two or more keys are pressed at once. Mechanical Enterprises resolved this by detecting the current in a specific bus line. The terminal for this line was fitted with a resistor so that current flowing out of that terminal would be limited. When a second key is pressed concurrently, it also feeds the same bus line, through another resistor of the same value. Two parallel feeds from the same source through identical resistances results in the effective resistance being halved, so the current will double. The higher current would demonstrate to the control circuitry that two or more keys were active at once, and it could then disregard any output until the correct current level was restored (such as when the first key completes its release). This is illustrated in the diagram above.
There is another problem with this approach: current is able to enter an inactive switch through any active bus line, pass through the current distributor, and then re-enter the bus. Thus, even an inactive switch will jam the bus. Two solutions to this problem are known:
- Fit every output terminal with a diode, so that current cannot pass into inactive switches; this was the approach taken by Mechanical Enterprises, and is illustrated above;
- Fit every output terminal with its own switch contacts, so that inactive switches are entirely disconnected; this was the approach taken by Micro Switch
The need to physically assign each switch with its own output code does require considerable assembly effort, since every switch needs to be modified individually.
Encoding switches were utilised, because Micro Switch KB encoding switches—introduced in 1966—were still in production at the end of 1969. However, no equipment has yet been observed containing encoding switches, with the exception of the garish example model in Micro Switch’s brochure.
A diode matrix is a grid of circuit pathways with the row–column intersections connected by diodes. A diode matrix is a precursor to integrated circuit ROM, where each bit is set by the presence or absence of a diode. Instead of using a silicon chip, discrete diodes are soldered to a printed circuit board. Each intersection with a diode passes current from the row into the column, encoding a 1. Where a diode is omitted, no current can pass, and this encodes a 0.
For computer keyboards, diode matrices are a more pragmatic approach to character encoding. They offer logic-free character encoding without the need for a space-consuming parallel bus or special switches. Instead, the diode matrix functions as a lookup table, into which each switch is connected. When a key is depressed, current passes through the switch into a row of the matrix. The switches themselves are not wired into a matrix arrangement: each one has its output wired directly to a row in the diode matrix.
In theory, all the keyboard’s logic circuitry then needs to do is read all the columns of the matrix to receive the character code. The following diagram illustrates a diode matrix layout suitable for this purpose:
Diode matrix lookup tables were a successful and commonplace design around 1970, with numerous examples discovered to date. However, most if not all of the examples discovered do not seem to operate in such an obvious manner. The unidentified Micro Switch KB–based example has a straightforward-looking matrix, but the codes defined by the diodes are not ASCII, and appear to be some kind of scancode set. The Potter Instrument matrix is particularly complex. The Scantlin diode matrix may apply simplifications to reduce the diode count, as there seems to be no more than two diodes per key. Tracing the matrices is not easy from photographs because the reverse side of the matrix PCB is often not depicted.
The following examples are known:
- Scantlin Electronics 830 (possibly ca. 1968)
- Potter Instrument KDR/KB 3100A (1970); note that some switches bypass the diode matrix and are routed directly to the edge connector, for direct detection
- Unidentified keyboard with KB switches (ca. 1970): the diode patterns are not ASCII, and the diodes and resistors at the side of the matrix appear to be for resistance-based keystroke collision detection
- George Risk 2-103-001-A-10 (ca. 1970): this model has all the diodes mounted vertically from conductor rails, and also appears to use resistors for collision detection
- UNIVAC 1701 keypunch keyboard (ca. 1971)
- UNIVAC 1710 keyboard (ca. 1972)
The diode matrix implementation was short-lived. A diode matrix consumes a lot of space, either at the back of the keyboard, or on its own circuit board below the switches, and it requires significant additional assembly work. Microchip-based implementations would soon render it obsolete. The diode matrix design retains the limitation of encoding switches in that rollover is impossible. The second key cannot be understood until the first key is released.
A unique two-of-n code is developed from the two isolated outputs available from each key switch. This code is used to address the keyboard encoder, thus eliminating the need for complex and costly scanning techniques.
“Two-of-n code” refers to a constant-weight code where two and only two bits are always set, and all other bits are cleared. Each of the two outputs from the switch will set one of the two required bits, resulting in a number that identifies the switch that was pressed. In such an arrangement, there is no need to scan the matrix, but the output from this process will not be the ASCII code. Additional logic (in software or hardware) will be required to translate these scan codes into ASCII codes.
Micro Switch also solved the clash problem of direct encoding by producing switches that only register for a tiny fraction of a second. By the time that the operator has pressed the next key, the previous key will have shut off its output even if it remains held. Although this can be achieved with a mechanical switch (as with Micro Switch PB Series or Cherry’s equivalent) this ability is much better suited to IC-based switches. Modifier keys such as shift do require switches that continuously generate output while held.
There are different options for converting two-of-N codes into the final output codes, such as ASCII. Micro Switch noted in 1973:
We offer a great deal of flexibility in providing codes that meet your exact needs. With MOS (large scale integration), a variety of electronic options is available which can simplify your system as well as increase its versatility. Where encoding and system requirements are less complex, TTL (medium scale integration) encoding is used. Our encoding techniques can generate any code that you specify and in the number of modes necessary for your system. Totally unrelated codes may be generated by the same keys. For instance, a keyboard may be specified that generates two modes of USASCII and two modes of EBCDIC. Since we do not have to logically pair our encoding for multi-mode operation, you may pair characters in any way you choose. And for quick turnaround on prototypes and low volume orders we have programmable ROMs. So you can have your exact code required without long delays for new encoded designs. In other words, with our encoding techniques there are almost no limitations.
An example of the TTL encoding arrangement is given in the Mini Bee Computer Terminal Service Manual from 1974 (PDF pages 75–78). Here, 8-to-4-line and 7-to-4-line decimal encoders are used to produce the high and low nybbles for each character from a grid similar to a diode matrix. The general principle involved is illustrated in the following highly simplified diagram:
The output code is divided up into its high and low nybbles, and each non-zero nybble value (0x1 to 0x7 or 0xF) is given a separate column on a PCB. One output from each Hall sensor is connected to a column representing a high nybble value, and the other output is connected to a column representing a low nybble value. Groups of columns are fed into binary encoders that convert the index of the input into its binary representation. The encoder outputs are then placed side-by-side to form the complete output code. This way, the output value of each switch is set directly in the circuit wiring, in a manner similar to that of the diode matrix.
The circuit diagrams for the Mini Bee keyboard demonstrate that, in reality, the circuit is more complicated. For example, when the control key is held on an ASCII keyboard, bits 5 and 6 must be suppressed, while with shift held bit 4 must be cleared for number and symbol keys and bit 5 must be cleared for letter keys if the keyboard supports separate uppercase and lowercase. The encoder for the high values (9–15) of the nybbles must also set the highest bit when an input is active. The Mini Bee keyboard also appears to use an electrical monitor to detect clashes instead of pulse switches to prevent them, even though the service manual is from 1974 and pulse switches existed by 1973. Additional circuitry will be present to handle the Repeat key used to request auto-repeat. Alternatively, this functionality could all be handled in software by giving the modifier keys their own dedicated lines on the PCB edge connector, allowing the operating system or ROM monitor the ability to make the adjustments. As noted later, microcomputers moved all this processing to the operating system, where code is cheaper than keyboard control hardware.
The diagram above shows that each switch is connected to two IC inputs using a grid. This is achieved using a double-sided PCB, with the grid columns on side and the grid rows on the other, with interconnects to assign each sensor output to a value. Switch outputs are fed into one axis of the grid, and the other axis is fed into the encoding circuit. This grid arrangement is visible in most of the keyboards in Micro Switch’s 1973 brochure. The use of a generic grid on the PCB allows the character encoding to be changed completely without needing to redesign the PCB or exchange any of the circuit components: the entire character encoding is defined solely in the interconnect pattern set in the grid. Detailed photographs of a keyboard using a very similar (if not identical) circuit to that of the Mini Bee keyboard can be seen in Micro Switch keyboard model 64SW1-4. The difference between the 64SW1-4 circuit and that of the Mini Bee keyboard appears to be minimal at most (although they use different PCBs); both use an electrical monitor circuit to detect keystroke clashes, and TTL binary encoding using RW-10038 and RW-10039 ICs, fabricated in the case of 64SW1-4 by Motorola as custom Micro Switch parts. The PCB used for the Mini Bee keyboard and the standard teleprinter keyboard model 53SW1-2 does however use a customised wiring arrangement without a generic grid.
Since the early 1970s or so, the standard way of wiring switches in a keyboard is a matrix. This is a grid of wires, with each switch placed at an intersection between a row and a column. Actuating a switch connects its row wire and column wire together. This way, each switch is identified by its position in the matrix. Circuitry in the keyboard scans each row in turn, looking to see which columns are active. The following illustration shows a portion of a switch matrix, with diodes fitted.
In the diagram above, you will see that the matrix layout does not correspond to the key layout on the keyboard. (The layout of the matrix example above is taken from that of the BBC Micro, but that keyboard only has diodes fitted to one column.) There are several reasons for this, not least the fact that the layout of a keyboard is not a regular grid to begin with. PCB routing requirements often lead to the PCB tracks being laid out very differently to the logical matrix form that the encoding circuitry sees. The PCB track layout varies widely between manufacturers in terms of how closely it resembles the circuit diagram for the matrix.
The images below show the matrix layouts of a number of different keyboard models, both mechanical and membrane.
The matrix positions do not provide the ASCII codes of the keys, but the co-ordinates can be used to create internal identities that can be converted to ASCII codes or standard scancodes. The duty of converting the matrix positions to scancodes or character codes is transferred to microchips on the keyboard PCB. In some cases, the host computer system performs this role, in particular with home computers and portable computers with integrated keyboards. Laptop keyboards typically contain no logic circuitry at all, due to lack of space. The BBC Microcomputer has the matrix multiplexing performed by chips on the keyboard, to reduce the number of lines coming into the I/O controller, but decoding the keyboard is handled in the OS, triggered by an interrupt raised when any key is pressed; this is explained further below.
The matrix arrangement means that the number of keys that can be held simultaneously is unlimited. Having unlimited simultaneously-held keys—known as N-key rollover—does still require diodes, but now only one diode is required per switch, and for ease of assembly these diodes were often fitted into switch in the factory (as is, or was, the case with RAFI, Cherry, Siemens, Clare and others).
Since the 2000s, all external keyboards are driven by an internal microcontroller that keyboard scans the matrix, debounces keystrokes, looks up the scan codes, and transmits key presses and releases to the host using a standard protocol. Fully self-contained external keyboards date back to the 1970s, and dedicated protocols at least as far back as the early 1980s, but the changeover to keyboard protocols took time to complete as various lines of computer products died out. In the office environment, protocol-based keyboards with an internal microcontroller have been standard on PCs since 1983 (with the IBM Personal Computer XT) and on Macintosh computers since 1987 (with the Macintosh II, which adopted the Apple Desktop Bus protocol from the 1986 Apple IIGS). Other brands such as Fujitsu are not as widely understood.
TTL-based matrix encoding
Some keyboards provided the ASCII encoding entirely in transistor–transistor logic. There was no microcontroller and no software involved in the encoding process.
Radio Shack produced a TTL dual-mode ASCII keyboard kit for hobbyists. Part 277-117 comprised the PCB, IC Z1 (RS74H103) and the documentation. This was intended to be paired with part 275-1422, which was a monolithic switch assembly strongly resembling the type used in the DEC VT100 and the IMSAI IKB-2 (both thought to be Hi-Tek High Profile). The included documentation is available in PDF form at Bryan’s Old Computers under Digital Group documentation, specifically the section DG Systems. This document includes the assembly instructions, complete theory of operation, output codes, circuit diagrams and troubleshooting.
The age of the product is not known. The only known dated reference is in the Radio Shack 1977 catalogue, and the switch assemblies are likely to be surplus parts.
The output is split dual-mode. With Shift released, the alphanumeric keys output numbers and uppercase letters. With Shift held or Shift Lock engaged, the number keys produce symbols, but the letter keys produce control characters as though Control was held (the separate Control key has no influence on character output). The Shift keys themselves do not generate output of their own. Shift lock is electronic secretarial: press Shift Lock to engage, and either Shift key to release. The shift lock state is held in a flip-flop. The Control key does not affect the ASCII codes and must be detected specially; the same applies to the Break, Clear, Here Is keys and the two unmarked keys. These six keys produce bit patterns 1000 0000 to 1000 0101, with the eighth bit (called “E”) indicating that a special key was pressed; this is instead of giving the keys dedicated control lines on the edge connector. Two approaches are offered for dealing with these special keys.
The complete assembly required six capacitors, eleven resistors and eighteen ICs; the complete list of ICs is as follows:
|RS74H103||Dual, edge-triggered J-K flip-flop||1|
|RS7473||Dual, J-K flip-flop||2|
|RS74193||Synchronous 4-bit up/down counter||2|
|RS7413||Dual, 4-input Schmitt trigger||1|
|RS7475||4-bit bistable latch||2|
|RS7402||Quad, 2-input NOR gate||1|
|RS7400||Quad, 2-input NAND gate||2|
|RS7410||Triple, 3-input NAND gate||2|
|RS7420||Dual, 4-input NAND gate||2|
Both positive and negative logic output is offered, on alternative lines on the edge connector (a complete set of lines for each of positive and negative logic, with the customer expected to determine which is required and use the correct set of lines). A Repeat key is provided to enable auto-repeat.
No explicit debouncing seems to be performed. The product documentation states:
The keyboard scan principle, which has been used on all recent calculators, has the advantage of minimized effects of key bounce. (Key bounce is that tendency of a key to chatter, or double-entry, when pressed or when released.)
More advanced output was certainly possible; it is likely that this design was deliberately simplified to suit the target market, being hobbyists with simple computers that were uppercase-only. Lowercase text would make its debut on microcomputers soon afterwards.
Host-based matrix encoding
Host-based arrangements use the host equipment to identify the keys pressed. For example, the host could be a computer where the operating system is partially or wholly responsible for the keyboard operation.
Acorn BBC Microcomputer
Acorn produced a hybrid software–hardware solution for the BBC Microcomputer in 1981. Because the keyboard is integrated into the case, placing a dedicated controller onto the keyboard would be wasteful. However, it would also be wasteful for the 2 MHz 6502 CPU to be continually used to check the keyboard. Additionally, there is a limit on the number of I/O lines available from the I/O controller to which the keyboard circuitry is connected. A compromise was reached where the complex processing is handled by the operating system, but the keyboard itself was responsible for detecting keyboard activity and multiplexing the matrix lines. A total of seventeen lines connect the keyboard to the motherboard, including the matrix row and column numbers (four and three bits respectively), the software-level reset line, the multiplexing clock, and the LEDs. The complete circuit diagram can be found on the BBC/Master Circuit Diagrams at MDFS, reproduced (uncredited) from page 490 of the Advanced User Guide (note that what appears to be “.5V” is really “+5V”). A simplified diagram is shown on the Arduino forum, but it mistakenly omits all the diodes and incorrectly shows all eight columns connected to the NAND gate.
The matrix itself comprises ten rows of eight columns. The rows and columns are both multiplexed by chips on the keyboard PCB (the row multiplexer is a BCD-to-decimal decoder). When no keys are pressed, the keyboard uses a binary counter to continually scan the matrix rows, fed by a 1 MHz clock signal from the motherboard. This counter controls the row multiplexer, and the columns are ignored. The matrix scanning is thus independent of the operating system.
Seven of the eight columns connect to an eight-input NAND gate. When a key is pressed, it brings that input to the NAND gate low, causing the NAND gate’s output to go high: the gate output indicates whether any key in the row being scanned is pressed, without being aware of which key, as the column multiplexer is not used at this stage. The NAND gate output is used to signal an interrupt, allowing the operating system to become aware of keyboard activity. From this point onwards, the key-pressed interrupt is shut off, and the operating system scans the matrix directly by taking control of both multiplexer chips, giving it the ability to read each key position on demand.
Each key is assigned an internal scan code; these codes are held in a 70-byte look-up table in the operating system ROM, in 10-byte groups spaced apart at 16-byte intervals, interspersed with 6-byte blocks of data and code to make use of the spare bytes. This look-up table converts from the scan codes to ASCII codes. The scan codes themselves are binary-coded decimal (BCD), where the high nybble is the column number and the low nybble is the row number, taken directly from the values of the two multiplexer chips.
According to Professor Steve Furber, one of the engineers responsible for the design, the operating system handles de-bouncing by checking every millisecond to see that the keys remain held; the 1 ms timer interrupt is used by the operating system for this purpose. Once a fixed number of check cycles have elapsed, the key is deemed to be pressed, and if it remains pressed, auto-repeat is triggered. He also notes that once the last key is released, the operating system re-establishes the key-pressed interrupt and relinquishes the scanning duty back to the keyboard’s on-board logic circuitry. Those who understand 6502 assembly language can determine this from the full MOS 1.2 disassembly at MDFS; do note however that some of the look-up table blocks mistakenly have the least-significant nybble of their address given as &A instead of &B.
Rollover is fixed at two keys, as two addresses in the 6502’s zero page (used for the most frequently-accessed operating system data in Acorn MOS) contain the two keys currently detected, not counting control or shift. If the number of keys held simultaneously increases incrementally, the first two keys will be detected. Pressing a ghosting combination simultaneously may result in a ghost being one of the two reported keys, and games and other software that request specific matrix positions be checked will be subject to ghosting.
The keyboard design contains a couple of other curiosities. The final column of the matrix is isolated from the NAND gate, which instead receives a continual 5 V feed for its eighth input. Of this column, eight rows collectively form a single-byte configuration word in the manner of NVRAM (curiously, this is not done with a single eight-column row). The ability of the keyboard to scan any matrix position on demand allows it to read this configuration word during start-up. The eight bits can be set by wire links or by a DIP switch block, either option being fitted to two rows of eight holes on the PCB. This entire column is diode protected, as otherwise any start-up options set would result in ghosting. The remaining two row positions for this column are Control and Shift, also diode protected, and also isolated from the NAND gate. This indicates that neither Control nor Shift can alert the operating system; pressing for example Control+A would only generate an interrupt as A is struck, after which the operating system’s controlled scan would detect that Control is held. These two keys will also not generate ghosts if they are held in conjuction with two other keys.
The operating system provides a call (OSBYTE 121) to allow user code to scan the matrix for a specific key or for any key above a particular scan code; a second call (OSBYTE 122) scans the matrix to locate any single key pressed above scan code 16, which ignores Shift, Control and the eight start-up options. Steve Furber mentioned that games are able to bypass the operating system and read the keyboard directly, which may improve performance by removing all the interrupts relating to keyboard handling. Note that one key is not present on the matrix at all, specifically the Break key which requests a restart of the operating system. The Break key is wired to its own reset line and functions independently of the rest of the keyboard. (Having a single key to restart the operating system proved troublesome and in the later BBC Master Series machines it could be locked out with a screwdriver.) Nonetheless, the user could still bind an action to that key, as it was a software-level restart rather than a hardware-level reset.
Keyboards of the 1970s frequently reported the character codes of the keys pressed. These codes were often ASCII: pressing the A key would output 0x41 (ASCII 65, “A”) to the host equipment. Pressing the return would send 0x0D (ASCII 13, carriage return); alternatively you could send 0x0A with the Line Feed key.
The IBM Personal Computer XT—introduced in 1983—used a proprietary keyboard protocol based on scancodes; when the clone market took hold, the XT keyboard protocol became a de facto standard, as did the AT keyboard protocol after the IBM Personal Computer AT (released a year later in 1984) was cloned. Before this, ASCII was the de facto standard output. ASCII keyboards could be paired with the kit computers; the Apple I did not ship with a keyboard, and the customer could connect it to any ASCII keyboard available on the market. This could be a hobbyist kit keyboard (such as the RS 277-117 described above) or any off-the-shelf keyboard, including widely-available purpose-built and surplus units.
A major limitation of this approach is that keys not defined in the character set cannot be reported. ASCII has a limited repertoire of 32 special characters, including tab, carriage return and space, as well as special codes for transmission control. However, the functions available on modern keyboards, ranging from Print Screen to Japanese input mode, were all outside of the scope of ASCII.
Additionally, ASCII keyboards did not necessarily make the modifier keys known. Pressing the A key would generate 0x41 (“A”) while pressing Control+A would generate 0x01 (start of heading). Pressing 1 would generate 0x31 (“1”) while pressing Shift+1 would generate 0x21 (“!”). The keyboard did not give the computer a choice: the modifier key would be handled internally and the modified ASCII code reported. This is very similar to how many keyboards now have an Fn key that causes the scancode of the key to change completely, without the host system being aware. Sticky Keys relies on the operating system being able to detect modifier keys separately, which is not possible with a standard ASCII keyboard.
ASCII keyboards also differed by whether or not lowercase was supported. It was normal for 70s computers to not understand lowercase: the 1976 Apple I, 1977 TRS-80 and Apple II and 1980 Acorn Atom for example were all uppercase only. The Shift key on uppercase-only keyboards did not affect the alpha keys. In Cherry’s Switches & Switches Catalog C-73, their product range included B80-3766 ASCII tri-mode with support for uppercase and lowercase letters, and B70-4753 ASCII quad-mode with support for uppercase letters only.
Modern keyboards report key presses as scancodes. A scancode is an arbitrary but fixed code assigned to each key. Some keys such as Enter and F1 have scancodes with a one-to-one relationship to the function of the key. In contrast, the scancodes of alphanumeric and symbolic keys do not define the result of pressing the key. For example, AT scancode 0x10 will result in a Q being typed on a QWERTY keyboard, and an A on an AZERTY keyboard. The host computer can interpret the keys as it desires, by translating scancodes to any choice of output characters or actions. A major advantage of scancodes is that they are capable of reporting non-printing keys, such as F1, Menu or Insert, that have no ASCII code.
Another advantage of scancodes is that they simplify the logic circuitry on the keyboard. The keyboard’s on-board circuitry is no longer required to store or generate ASCII codes; it can simply report the values of the row and column multiplexers used to scan the matrix, combined into a single integer. The more difficult work of converting matrix positions to character codes could then be transferred to the host system; this can be seen in the BBC Micro example above, where the operating system uses a look-up table to convert matrix positions into ASCII codes.
Scancode-based keyboards also report modifier keys to the host; this can be with scancodes (as in AT) or within a bitfield (as in USB). In AT for example, left shift is scancode 0x2A, while in USB’s boot protocol keyboard interface it sets one of the bits in the modifier bit field. This allows the operating system to detect modifier keys directly, and filter them out or allow actions to be bound to them (especially in games). This was often impossible in older keyboards, where the modifier keys were not reported at all.
The historical term of “mode” is very similar to the modern term of “layer”: it refers to the maximum number of different output codes available per key. The budget desktop keyboards supplied with computers and available in retail are normally single-mode, because the modifier keys are managed by the operating system. Laptop keyboards are frequently dual-mode, because they need an Fn key to simulate the keys that are not physically present due to size constraints. More expensive keyboards may also be dual-mode, to offer media control functionality on the Fn layer.
The mode count is much more significant in the days of TTL-driven ASCII keyboards. A single-mode keyboard would only generate one ASCII code per key: there would be no shifted characters of any kind. A dual-mode keyboard might offer a Shift key for extra symbols, or it may offer a Control key for generating ASCII control characters. A tri-mode keyboard could offer Shift and Control combinations but not both simultaneously: pressing Control+Shift+A would have to be interpreted as either Control+A or Shift+A (Cherry’s B80-3766 gave precedence to Shift under these conditions). A quad-mode keyboard might extend the modifiers to permit Control and Shift simultaneously. For example, Cherry advertised B70 Teletypewriter Series quad-mode keyboards with uppercase-only output. The key marked “M”/“]” for example produces “M” when struck by itself, and “]” when used with Shift. Control+M emits 0x0D (carriage return), while Control+Shift+M equates to Ctrl+] and thus produces 0x1D accordingly. One keyboard with this functionality is their B70-4753 model.
RS’s 277-117 could charitably be described as 2½ modes: the Shift key produces shifted symbols or control codes depending on which key is pressed. This is instead of having separate Shift and Control keys, although there is a Control key. (The logic may have been designed for a different surplus keyboard which did not have such a key, or it may have simplified the TTL circuitry.)
The exact nature of the different modes is entirely implementation dependent. Micro Switch SW keyboard model 51SW12-1 is a non-ASCII keyboard described in the 1973 catalogue as dual mode: the first 6 bits identify the key location, and the 7th bit indicates Shift. At the same time, the SW brochure advertises it as 6-bit mono mode, presumably on account of the fact that the Shift key is signalled separately and does not influence the scancodes. Either view is correct, depending on whether you consider the scancodes to be 6-bit or 7-bit.
Typical USB keyboards (using the boot protocol) respond to the computer with the list of keys currently active (up to six normal keys and up to eight modifier keys). The AT protocol used on PCs before it (and still in limited use) sends a message to host each time a key is pressed or released. The host system (e.g. computer operating system) keeps track of which keys are active.
Some keyboards would instead only indicate keystrokes: the host would receive a message when a key was pressed, but not when it was released. ASCII keyboards operate this way. If auto-repeat is desired, this has to be provided by the keyboard itself. A common method for providing auto-repeat was to have a dedicated Repeat key which, when pressed, would retransmit the most-recently-pressed key. This is demonstrated in the RS 277-117 keyboard above; Micro Switch also offered this option.
Transmitting only the keys as they are struck (and not when they are released) was an approach used by Micro Switch with some of their keyboards, as a way to provide N-key rollover. This was an acceptable limitation for the time, but as computer prices plummeted and computers became widely available to home users, being able to detect which keys were held became necessary for any computers wishing to accommodate games with keyboard input.
Logic circuitry can take the form of “postive logic” or “negative logic”. In positive logic, true is indicated by a higher voltage (such as +5 V) and false is indicated by a lower voltage (typically 0 V). In negative logic, true is indicated by a lower voltage than false. Negative logic was created to accommodate older transistor technology, but as both methods have advantages, they can be used together.
Keyboards that output scancodes or character codes directly need to generate the correct logic levels for the equipment to which they are interfaced: the output must use either positive or negative logic as called for. The type of logic used can be defined in the factory by the circuitry within the keyboard (and thus the user must buy the appropriate model for their needs) or, as with RS’s 277-117, both logic types can be provided simultaneously, with the user expected to wire up the appropriate outputs for their equipment.
The simplest signalling option is simply to expose the PCB traces to the switches on an edge connector on the PCB. In this arrangement, there is no encoding at all: each switch has its own contact on the connector, with a common ground. Keypads often used this approach, although those too could be encoded. There are also unencoded matrix keyboards, that expose the matrix rows and columns on the edge connector, but these are typically proprietary units for use inside specific equipment.
The simplest option for encoded keyboards is very similar: an edge connector that provides all the bits of the character code or scancode. As noted, these can be positive or negative logic, or a mixture of both. Such connectors may also have separate conductors for non-encoded keys, such as those without ASCII characters. Cherry’s B80-3766 ASCII keyboard has 7-bit output with parity, as well as a 12-key pad on the right of non-encoded keys.
ASCII keyboards could also provide serial output. In Amkey’s 1991 EEM entry, they advertise TTL serial, RS-232, RS-232C and RS-422 models, with RS-423 also available. GRI also offered TTL serial, RS-232 and RS-422. Both manufacturers offered a choice of bit rates.
There are also dedicated protocols designed to handle keyboard operation. These include IBM’s proprietary protocols for the PC/XT and PC/AT, both widely adopted by clone manufacturers, and Apple Desktop Bus (ADB) used with the Apple IIGS and the Macintosh II and later Macintosh models. ADB was a general purpose 16-device desktop protocol with daisy chaining, while the PS/2 protocol introduced with the IBM computer of the same name still required separate mouse and keyboard ports, and peripherals would not function when connected to the wrong port.