(See fork for my extension of XFree86 server which make a more extensive use of keyboard.)
PC keyboard is composed of the electronic part and an electro-mechanic part.
The latter can be thought of as 3 parts:
Now, all those connections/wires can be transformed into an 'electrically' equivalent diagram, where rows are (parallel) horizontal lines, and columns (orthgonal to rows) vertical lines.
With this model, we can label the wires: 1 ... 8 the rows, 1 ... 16 columns.
But what happens with such transformation to the keys? The layout will be changed: the keyboard rows don't correspond to rows in this orthogonal electrical schema.
To answer it, we need to know, how the electronic part uses this electro-mechanic part.
My guess (fixme: find confirmation!) is that the chip periodically loops over the rows and sends in turn to each one a signal, and in turn 'senses' if the signal arrives in the columns.
This C code illustrates it:
for (int i=0;i<8;i++){
send_signal_to_row(i);
for (int j=0;j<8;j++){
if (sense_signal_on_column(j)){
the key (i,j) is _probably_ down. //
}
}
}
I wrote "probably". This is because, if I press down 3 keys, which form 3 vertices of a rectangle, for example (row 3, column 2), (3, 5) and (8, 2), then there is no way to see, if the 4th vertex key is down or not, and thus it's not clear, if both 4 are down, or which one of the other 2 vertices. This is because the 2 edges shortcut what the 4th vertex key would switch-on.
Let's illustrate the confusion:
Keys A,B are down(pressed), and now i press D. The keyboard controller 'knows' the A,B were already down.
When the signal is sent down the row 2, and the chip is sensing the column 4:
1 ----- A ---->----->B
^ |
^ v
| v
2 ----> D ---------- C
| |
| v
3 4
Lemma: Pressing 2 (distinct) keys on a common line (be it a column or a row), makes all keys on the 2 orthogonal 2 lines passing through the 2 keys (rows or columns) unusable.
If you are really interested in how i constructed the key matrix, see here (included a Scheme program)
The matrix in my old MS natural keyboard is: (only the first 5 column are important for the following text)
'(("5" "8" "numlck" "f2" --- "kpenter" "tlde" --- "menu" "f4" "f12" "space" "f10" "f6" "7" "f8")
("4" --- "kp-" "f1" --- "scroll" "esc" "pause" "print" "f3" "f11" "right" --- "f5" "6" "f7")
("t" "e" --- "pgdown" "lock" --- "tab" --- "kp*" "kp9" "end" "rwin" "p" "ae11" "u" --- )
("b" "-" --- "x" "rctrl" --- "z" "rshiftr" "kp1" "kp." "kp0" --- "down" "enter" "m" ".")
("v" "c" "ralt" "s" --- --- "<" --- "kp+u" "kp3" "kp2" "bksl" "minus" "left" "n" "l")
("g" "k" "lalt" "w" --- "kp+d" "a" --- "kp4" "kp6" "kp5" "bksl" "ac11" --- --- "ad11")
("f" "k" --- "2" "lctrl" --- "q" "lshift" "kp7" "del" "kp8" --- "ac10" "ad12" "h" "o")
("r" "i" --- "pgup" --- "lwin" "1" --- "kp/" "ins" "home" "up" "0" "ae12" "y" "9"))
As an example of the importance of the lemma, let me state this sad conclusion:
RALT & LALT keys are designed on this keyboard (and on all other keyboard i've tried) not to be used contemporary. I.e. they are on a common line (3rd column), and thus evey key on any of the 2 rows is unusable with them. So if i press "s" "w" "c" "k" .... nothing will happen, the keyboard will report "undecidable".
If we modified the column wires, so that "ralt" gets the position of "s" and "s" gets to the 5th column (for now unused position), there would be only 1 non-working key, "w".
(With the exception of the pause key,) all keys when held down for a certain time, auto-repeat. The down code is repeated until the key is released. If two or more are pressed together, only the last key pressed is repeated.
The repeat stops when the key pressed as last is released, even if the other keys are still depressed. The delay is usually 500ms and the repeat 10/s and can be modified.
my observation: Xfree/XKB (w/ soft repetition) works much better. If i press & let repeat 'x', then press Shift and release it, i get 'xxxxxXXXXXXxxxxxx'. In MS windows only 'xxxxx'.
The document lists the keyboard controller commands:
F6 Set default. Responds as the 'Default Disable' command, but does not inhibit scanning. Does not affect LED indicators.
FB 'Set key type typematic'
FC 'Set key type make/break'
FD 'Set key type make' Again, I'm not sure what these do. Unlike the 'set all' commands, these commands presumably act on single keys. The keyboard sends the ACK code, then waits for keyboard scan code(s). ACK is set after each scan code is received. Keyboard remains in the 'set type' state until a new command is received.
ED Set/reset status indicators. This command allows you to control the status LEDs on the keyboard. Keyboard responds with ACK and waits for a option byte, bitmapped as follows: b0-Scrollock, b1-Numlock, b2-Capslock, b3..7=0. A '1' bit turns the indicator ON.
Easy. Because USB is not a perfect replacement for PS/2 input devices.
In short, there is no possible way on any but the fastest of current machines for a USB mouse to approximate the responsivity of a PS/2 port mouse being sampled at 200Hz (the maximum rate the port will tolerate).