Jump to page content

Rollover and lockout

Contents

Overview

Rollover is the ability of a keyboard to report further keypresses before previous keys have been fully released. Lockout is a physical or electronic restriction that ensures that only one key can is reported or can be pressed at once. N-key rollover (NKRO) is normally defined as the ability to simultaneously detect an unlimited number of keys, but the definition depends on the context. N-key rollover is not a requirement for typing, but video games can require more than two keys to be held at the same time, and increased rollover capacity reduces the likelihood of the keyboard causing problems for game playing. This was especially true in the 90s before the rise of network gameplay, when two players would share the same keyboard, giving rise to abnormally high numbers of concurrently-pressed keys compared to the expectations from terminal, typewriter and computer manufacturers.

Historical context

It is taken for granted now that keyboards permit multiple keys to be pressed in rapid succession or held simultaneously. However, many early keyboard types in the 1960s and very early 1970s made this impossible, either physically or electronically. Invac’s photoelectric keyboards for example used a mechanical interlock to physically prevent more than one key to be pressed at once, because the sensing mechanism could not understand simultaneous key depressions. Keyboards using electrical encoding switches, such as those from Mechanical Enterprises and Micro Switch, did not physically prevent simultaneous keystrokes, but as these keyboards too could not understand such actions, output from the keyboard was suppressed when two or more keys were operated at the same time.

In US patent 3698531 “Solid state switch” filed in October 1970, ITW noted:

Roll-over is the tendency of a particularly fast operator to depress a second key before a previously depressed key is released. A certain degree of roll-over is desirable because it permits increased typing speeds. However, if roll-over is excessive, it results in a double strike. That is, the keyboard will emit signals which are a combination of the signals which each of the two keys would emit if depressed individually.

In prior art keyboards of the type employing electrical contacts mechanically closed by depression of a key, the problem of roll-over was overcome by employing mechanical interlocks. These interlocks permitted one key to be partially depressed before another key was released, but would not permit two keys to be depressed far enough so that the contacts associated therewith were closed at the same time. In this type of keyboard, the problem of transfer timing was solved by providing an additional set of contacts. This set of contacts would not close until after the data-representing contacts were fully closed. The signal produced by the additional set of contacts was then used to strobe a set of gates which gated the data-representing signals from the keyboard into the processor.

N-key rollover is briefly mentioned in a Cherry advertisement for their reed switch keyboards in Electronics magazine in August 1970, with the following definition:

In addition, N-key rollover can be added on a small second-level board. A typist can then press several keys and produce the proper outputs from each key regardless of the sequence with which the keys are released.

N-key rollover is discussed in the Focus on Keyboards article in Electronic Design magazine in 1972 [ED1972-FOK]. Here, N-key rollover is said to be a term originating at Micro Switch, indicating that during fast typing, the keystrokes are transmitted in the correct order no matter how many keys are not yet released. N-key rollover (“NKRO”) is contrasted here with “2-key rollover” (“2KRO”), defined as being where “an electronic interlock prevents errors when two keys are simultaneously depressed”, a fundamental limitation of some keyboard types. This early definition of two-key rollover is very different to the modern definition, in which the keyboard guarantees that a minimum of any two keys can be pressed or held simultaneously. This definition of 2-key rollover is also referred to as “N-key lockout”.

The article goes on to say:

Key Tronic proposes still another approach—selective N-key rollover, a combination of 2KRO and NKRO. The keyboard becomes locked after a fixed number of keys have been depressed—and are held depressed. Key Tronic claims that this approach is less expensive than NKRO but just as advantageous.

It is not clear what switch type is being described here. Key Tronic are best known for their capacitive keyboards, but this article could have been referring to their reed keyboards. N-key rollover is also discussed in the 1976 Focus on Keyboards article in Electronic Design magazine [ED1976-FOK]. Here, the details are even less clear. N-key rollover was shown by studies to result in 30% fewer errors compared to two-key rollover, and the article indicates that the 10–15% higher cost for N-key rollover is justifiable for workloads involving extensive text input. However, modern keyboards clearly demonstrate that N-key rollover is not a real requirement: virtually all keyboards produced today are two-key rollover—with optimisations made to accommodate modifier keys—and typists do not see errors resulting from not having N-key rollover. The article mentions a number of ways in which two-key rollover can produce unexpected or erroneous output, but none of these limitations exist with modern two-key rollover keyboards. N-key rollover does maintain an advantage for gamers in that there is no risk of blocked keystrokes from any combination of keys, but it is no longer a requirement for fast, accurate and reliable typing.

The 1976 article does also note the following, however:

If you do choose a rollover option, be warned: Not all options work exactly alike, even if called by the same name. There are many versions of each type. Even a single company can offer several choices. Key Tronic offers a choice of three types of two-key and four N-key rollover. Although Key Tronic explains its versions, many companies don’t.

The modern definitions of N-key rollover and two-key rollover are far more precise and clear-cut than the way that these terms were treated historically, when keyboard technology was still in its infancy, and the complex electronics required for reliable input were considered too expensive in many cases.

Sensing implications

Encoding bus

Keyboards that produced fully-encoded output (e.g. ASCII, EBCDIC)—which was standard practice in the 1960s and 1970s—had little need to detect or report key release, except for modifier keys. Keyboards of that era were typically only capable of identifying a single key at a time: with two more keys active simultaneously, neither key could be recognised. 1960s keyboards typically had all the switches wired to a common bus for the purposes of encoding (using either encoding switches or a diode matrix, and only one key could be active at once; with two active keys, the a collision would occur on the bus and the output would be incorrect or invalid. Photoelectric encoder keyboards had the same limitation. Various methods were used to detect collisions and suspend keyboard operation until the collision had cleared.

Rollover implementation involved methods of ensuring that overlapping keystrokes would be reported to the host and in the correct order. There was no need to independently register every key that was held, as keystrokes were only transmitted at the point of actuation. Keys that remained held could safely be ignored so long as further keystrokes could be detected unimpeded; this required a means to suppress keys once they had been initially detected.

Under these conditions, it made sense for switches to be active only for a brief fraction of a second (for example 0.1 milliseconds or less), as this would make collisions almost impossible during normal typing. As such, no matter how fast the keys are struck, it is unlikely that there will ever be two keys active at the same time. This arrangement provided “N-key rollover”: any depth of overlapping keystrokes would always result in every character being transmitted in the correct order. The diagram below illustrates the lack of encoding collision with pulse output:

Pulse output could be achieved electronically (with Hall effect switches that can shut themselves off, as was done with Micro Switch SW) or mechanically using a one-shot mechanism that releases the switch contacts before the key is released (such as Micro Switch 1PB870 and TEC pulse switches). In practice, few manufacturers appear to have created pulse-output switches.

For more conventional switches such as reed and standard mechanical types, collisions between keys was inevitable; even SW Series Hall effect keyboards were often sold with this limitation, using level switches instead of pulse switches. Under the premise that collisions will occur, the keyboard logic circuitry should detect collisions and suspend keyboard output until collisions clear; various methods exist for collision detection, including electrical current measurements and encoding validation. (Invac and one or two other brands used a ball bearing tray as a mechanical interlock to physically prevent two keys being pressed at once; this approach prevents rollover from occurring at all.)

Where two keystrokes overlap, this situation is recoverable. At the point that the second key actuates, there is a collision with the first key and the second key cannot be read. However, once the first key is released, the second key is left active in isolation and can be detected and reported correctly, albeit with a small delay caused by waiting for the first key to be released. The diagram below depicts such a sequence, with the hatched areas indicating collisions where the individual keys cannot be identified:

This approach is limited to an overlap with two keys. If the overlap extends to three or more keys, it is not recoverable and one or more keystrokes will be lost. This problem occurs because keystrokes other than the first or last are never detected in isolation: there is always a collision between two or more keys until the last-but-one key is released, and the keyboard is likely to not even be aware that this has occurred. The diagram below shows this occurring, with three keys pressed so quickly that the first has not fully released before the third has actuated:

Both significant overtravel and hysteresis worsen this problem, by increasing the amount of time that the key is likely to remain active.

Matrix scanning

From somewhere around the end of the 1960s onwards, matrix scanning started to take over as the standard encoding method in desktop keyboards. Matrix scanning guarantees that any two keys can be detected simultaneously without collision. However, detecting three or more keys simultaneously is dependent on the implementation details of the keyboard. Conductive sensing (mechanical, reed, conductive rubber and membrane keyboards) implemented as a matrix exhibits a weakness where current is able to flow backwards through active switches and exit the matrix on another row, causing the matrix scanning logic to detect a nonexistent keypress. These erroneously-detected, non-existent keystrokes are described as “phantom” or “ghost” keys, and the overall effect as “ghosting”; US patent 4106011 “Keyboard circuit” filed by Tektronix Inc. in 1975 uses both the terms “phantom key” and “ghosting effects” in relation to rollover, indicating that these terms date back decades. Dave Dribin’s Keyboard Matrix Help page explains the ghosting phenomenon in clear detail. Capacitive and inductive keyboards are reported to be immune to this problem, as are Hall effect keyboards when appropriately implemented.

Keyboards with a PCB are able to resolve the ghosting problem very simply (but at an additional cost) by using diodes to prevent wrong-direction flow through the matrix. There are at least two reported means of achieving N-key rollover on a membrane keyboard, but as the definition of “N-key rollover” has never been precisely used, and the full details from these manufacturers have yet to be found, it remains to be seen what arrangements these were.

The cost-effectiveness and simplicity of matrix scanning has led to its universal adoption; as a high level of rollover is more expensive to implement, rollover is limited on most keyboards to combinations of keys that can be pressed without a phantom keypress occurring.

Patents

Rollover management has been the subject of many patents, including those detailed below:

Company Patent Title Filed Published Notes
NCR US 3675239 Unlimited roll keyboard circuit 1970-09-14 1972-07-04
Illinois Tool Works US 3698531 Solid state switch 1970-10-26 1972-10-17 Rollover support for ferrite core keyboards, using six magnets
MOS Technology US 3792466 Keyboard entry system with n-key rollover and n-key lockout protection 1972-05-31 1974-02-12 This appears to be a patent for their 64-key single-chip encoder
Illinois Tool Works US 3978474 Keyboard with n-key lockout and two-key rollover protection 1975-07-15 1976-08-31
Oak Industries US 4420744 Keyboard crosspoint encoder having N-key rollover 1981-02-12 1983-12-13 Oak Full-Travel Membrane
Alps Electric JP H051485 キーボードのキ一出力方式 1984-07-24 1986-02-14 2-key rollover; published in English as US 4922248
Alps Electric US 4922248 Key output method for keyboards 1988-11-23 1990-05-01 US equivalent of JP H051485 (filed July 1984, above)

N-key rollover definitions

Standard

The standard definition of requires that the keyboard be able to independently detect every key, regardless of how many other keys are held at the same time. With keyboard protocols that provide interrupt-driven sequential press and release reporting, there is no signalling limit, but the operating system cannot necessarily memorise an unlimited number of held keys. Acorn MOS, designed around a 2-key rollover keyboard in the BBC Micro, reserves exactly two memory locations—two bytes—to remember up to two keys pressed during the last interrupt–scan event. (Here, only the existence of one more pressed keys is notified by interrupt, after which the OS scans the matrix to identify which two keys were held.)

USB is more awkward, because as a polled instead of interrupting protocol, it reports the list of keys currently held, not the individual press and release events, which in its most basic form is up to six keys plus eight modifiers (four left and four right).

Most keyboard designs require each switch to be wired in series with a diode to allow for independent key scanning. Without this, the number of simultaneously-detected keys can be reduced to as few as two, due to ambiguous readings from the circuitry when specific patterns of keys are held (“ghosting”, where extraneous keys are detected when electric current diverts the wrong way through one of the switches).

Micro Switch

Micro Switch effectively defined N-key rollover as the ability to press an unlimited number of keys in sequence (not concurrently) without the previously-pressed keys interfering with the detection of later keys. This was accomplished by having the switches only conduct current for a tiny fraction of a second: by the time the next key is pressed, the previous key no longer registers. This approach comes at the cost of being able to detect key release, which for typing purposes is irrelevant unless typematic repeat is desired. This method was not necessarily a disadvantage in context, because ASCII keyboards were prevalent, and they had no concept of press and release: the ASCII character was automatically transmitted to the host on keypress. Typematic repeat under these conditions was achieved by having a Repeat key, that was used in conjuction with another key to indicate that it should be repeated. A standard switch was placed under the Repeat key to allow separate press and release to be detected.

Each of 1PB800, SW and SN Series and SD Series provided press-only detection to this aim; KB series switches mechanically release the contacts, while SW and SD series solid state switches electronically shut off the output transistors to stop current flowing through them. SW and SN Series define the period that the switch conducts electricity to be 10–100 µs.

This definition is found in the 1973 Solid State Keyboards brochure.

Oak

US patent 4420744A filed in February 1981 covers achieving N-key rollover with a membrane keyboard, in particular their FTM keyboards. Their idea of N-key rollover is misleading, however. They do not offer true N-key rollover; rather, they describe a means to allow any number of simultaneous keypresses excluding phantom conditions: the controller will output every key pressed except for any set of keys that are involved in a ghost (or “phantom”) situation. The scan rate should be sufficient for all keys to be registered so long as they are pressed and released in sequence (as with fast typing) where the previously-blocked keys will get detected as the ghost situation clears. However, this is not the same as proper N-key rollover where any rollover sequence is valid including those that would trigger phantom keys on a lesser keyboard.

Behaviours

N-key lockout

Commonly offered by single-chip encoders in the 1970s, N-key lockout is a software implementation of the hardware constraints of certain encoding types such as photoelectric, where only a single key is read at once. Matrix scanning stops as soon as an active key is detected, and resumes once the key is released. If a second key is pressed before the first key has fully released, it will be reported in turn if it remains detected once the first key has become inactive.

N-key rollover

N-key rollover means that the keyboard will continue scanning the matrix once a key has been detected. The literature for encoder ICs indicates that, upon key detection, the detected key undergoes a debounce cycle, and matrix scanning is suspended until the debounce cycle completes. Once debounce completes, the encoder will flag that key as active in RAM, report its output code, and resume scanning the matrix for any other keys pressed. On subsequent passes, any active keys already flagged in RAM as active will be skipped.

IBM Personal Computer and PS/2 keyboards, which were microcontroller based, work similarly: as a key is detected, it is reported immediately. However, unlike earlier systems, key press and key release are reported separately. This allows the operating system and application software to see which keys are held, which is important for games and other applications. As such, the onus in on the operating system to remember all the active keys. This may be where the notion has arisen that N-key rollover means that the host be able to detect which keys are pressed at any given time.

With USB, the host is required to poll the keyboard for active keys, and the keyboard responds with a list of keys currently active. However, USB also permits a key-pressed bitmap spanning the entire keyboard, allowing the state of every key to be returned on each polling cycle.

2-key rollover

2-key rollover is a subset of N-key rollover where only a small number of simultaneous keypresses can be reported. In Acorn MOS (introduced in 1982), the keypress limit is literally two keys, as two bytes in the 6502’s zero page are set aside to record up to two detected keys. In modern keyboards, 2-key rollover guarantees that at least two simultaneous keypresses can be detected; the actual number may depend on the controller’s knowledge of the matrix, with scanning for additional keys being halted once a ghost condition is met.

Conductive-sensed matrix keyboards without diode protection typically employ some method of ensuring that phantom keypresses do not appear when too many keys are pressed simultaneously, but this is not always the case. Pages 64–65 of the Amiga System Programmer’s Guide from Abacus in 1987 describes how the Amiga 1000 keyboard has no such protection, and invites the reader to hold A, Q and Tab at the same time and watch the Caps Lock key light up unexpectedly. The author goes on to say that “This effect can be seen in many inexpensive matrix keyboards; it isn’t limited to just the Amiga.” (While this claim may be true, it is hardly a flattering comparison to make of the Amiga 1000 keyboard, as it was not an inexpensive machine!)

Two-key rollover requires the matrix to be carefully laid out in order for keyboard shortcuts involving three or more keys to work correctly. Older keyboards may not support more modern keyboard shortcut practice correctly, as ghosting conditions are triggered, resulting in phantom keys or the shortcut being completely blocked. For example, the Monterey K102 was found to have the following restrictions on certain shortcuts:

Shortcut Possible combinations Rejected combinations
Control + Alt + F11 Right Alt + Left Control + F11 Left Alt + Right Control + F11
Control + Alt + F12 Left Alt + Right Control + F12 Left Alt + Left Control + F12
Right Alt + Left Control + F12
Control + Shift + Home Left Control + Left Shift + Home Right Control + Right Shift + Home
Left Control + Right Shift + Home
Right Control + Left Shift + Home

Implementing N-key rollover would have prevented these limitations, making the K102 (and presumably also the K101) more usable on modern computers. Instead, older keyboards can end up unsuitable for some tasks where modern keyboards with more carefully-planned matrix layouts do not block keyboard shortcuts.

6-key rollover

6-key rollover is a limitation of the USB boot protocol, designed to ease the burden on BIOS developers for handling keyboards. As 2-key rollover is perfectly adequate for most purposes, few keyboards have any need to surpass this limitation, but video games requiring extensive keyboard manipulation may find this limit to be a problem. In practical terms, increasing the level of rollover brings diminishing returns considering that few users have more than ten fingers and thumbs, and being able to hold any six arbitrary keys is already surplus to requirement for most if not all serious applications.

Implementations

Conductive sensing

Conductive sensing using a key matrix requires a diode at each key position to prevent incorrect key detection. IMSAI’s IKB-1 for example specifies diode type 1N4148, with 1N914 as a permissible alternative.

Membrane keyboards

A major limitation of membrane keyboards is that diodes cannot be soldered to the membranes to provide current flow. Nonetheless, at least two membrane keyboard manufacturers have claimed to achieve N-key rollover on a matrix keyboard:

Mitsumi

Various Mitsumi membrane types of the 90s, including Mitsumi KUJ, KUK and KUL types featured “chip diode on membrane” to accomplish N-key rollover on a membrane keyboard. No further details are known, and no such keyboards have ever been examined to determine what they meant specifically. No other manufacturer is known to have ever used such a technique, despite the obvious advantages of such a feature on low-end gaming keyboards.

Fujitsu

Fujitsu’s FKB74xx and FKB76xx datasheets also indicate that N-key rollover is possible on their membrane keyboards, using their “resistance matrix method”:

Nキーロールオーバーの対応当社独自の抵抗マトリクス方式により,メンブレンキーボードながらNキーロールオーバーを実現できます。

Geekhack forum topic German Fujitsu (former Siemens) factory in Augburg closing in 2020 mentions “chip/SMD-on-membrane technology” briefly, but no clear details are given, and nothing matching the description appears to have been discovered.

Alps

Alps advertised N-key rollover with their KFNR Series and KFNS Series full-travel membrane keyboards; the following descriptions were provided of the optional N-key rollover of KFNR Series:

See also