Actually, the approach has changed with time.
Back when I built my own keyboard from scratch, the controller
used a matrix for most keys, but the modifier keys were
separate. And the modifier keys, actually "modified" something
at the hardware level. So the shift and control keys, used
separate wires and were monitored separately. The matrix is
scanned to detect ordinary key closures. That keyboard design
was so old and crusty, I think the chip may have been NMOS.
+ --- Ctrl ---- Old --- rows--------- | | |
+ --- Shift --- Controller --- columns --+ | | |
| | | |
+---+-+-+
I was checking a datasheet for a USB keyboard controller,
and *all* the keys on that, were on the matrix side of the
chip, including the control key. So it looks like this
at the hardware level.
New --- rows--------- | | |
Controller --- columns --+ | | |
| | | |
+---+-+-+
That means that *something* has to keep track of
closures of shift and control. It might be done
inside the keyboard chip, or it could be tracked
somewhere else.
The problem with such an approach (put everything on
the scanning matrix), is avoiding ghosting, and
implementing N-key rollover. On my home-made
keyboard, I used a diode per key, which made
my keyboard N-key rollover (ghost free). I have not
noticed that in retail keyboards - I have not seen
a keyboard PCB, featuring a diode at each key crossing.
http://en.wikipedia.org/wiki/N-key_rollover
Another possible difference, is my homemade keyboard
only did "key down" codes. There were no "key up" codes.
I understand keyboards now, may do both, not really sure.
The datasheet I was looking at, did not clarify that issue.
The datasheet showed hex codes for what happens when a key
is pressed, but did not offer any more details than that.
You'd think if it was doing key up and key down, there'd
be two tables of values, rather than just one table.
Maybe there is a byte pre-pended that says whether its
keyup or keydown, but that was not clear.
43,B8,00,00, Row 16 column7 Normal Key: <Ctrl-R>
42,81,00,00, Row 16 column1 Normal Key: <Ctrl-L>
00,00,00,3D, Row 3 column7 Normal Key: <C> <--- Something tracks
00,00,00,0A, Row 4 column 7 Normal Key: <V> shift state... No
small c or small v.
43,CD,00,00, Row 15 column7 Normal Key: <Shift-R>
43,94,01,00, Row 15 column4 Normal Key: <Shift-L>
00,00,00,1A, Row 2 column4 Normal Key: <Caps> <--- Caps Lock?
I have always found tracing the path from keyboard to screen
on a computer, to be pretty torturous. Even before sitting
in this chair, I have tried to research this topic for other
computer systems (eons ago), and come up empty. I could never
get all the details in one place. If I knew of a good
tutorial, I'd offer it.
Paul