Actually, when you press any key, two distinct events are recorded and sent to the computer: a MAKE code (the user pressed the key) and a BREAK code (the user released the key). You can see this in action in the "DOWN" and "UP" messages in the Switch Hitter screenshot. This is how the operating system "knows" that, say,
Shift is pressed, so 0x27 should produce a
':' instead of a
';'.
So, two characters per key? More like "up to four"
(up to six, if you're Canadian; you don't want to know). A keyboard layout recognizes four distinct layers ("levels", in ISO9995 parlance), that alter the meaning of the unique scan code of an alphanumeric key:
- Base ("regular", for ISO9995): no modifier keys are pressed while the alphanumeric key is pressed and released.
- Shift: either Shift key (B99 or B12) is pressed while the alphanumeric key is pressed and released.
- AltGr: the AltGr key (A08) is pressed while the alphanumeric key is pressed and released.
- AltGr-Shift: both the AltGr and either Shift key is pressed while the alphanumeric key is pressed and released.
In this example from the Danish layout, the B07 ("VK_M", in Microsoft's parlance) key is made to be capable of producing three characters:
'm' in the base layer,
'M' in the Shift layer and
'µ' in the AltGr layer; the AltGr-Shift layer is unassigned and does not produce anything.
The E12 ("VK_OEM_4" for MS) key produces the acute accent dead key in the base layer, the grave accent dead key in the Shift layer and the (not quite dead) character
'|' in the AltGr layer.
Those two screenshots correspond to MSKLC, Microsoft's program that allows a user to create his or her own adapted or entirely custom layouts. I used it first to both extend both es-ES and es-LA, to cover their omissions, and then I created a third Spanish layout, es-IB, with the ultimate (if rather Quixotic) intention of replacing both... and this is what I daily drive:
Every red symbol here is a dead key — fourteen dead keys for diacritical signs (
"áàāȧǎ..."), five more for "alternate letters" (
"əǷß..."), miscellaneous (
"⇒¦♠⋮☑ⁿ...") and currency (
"₩€¥£₱₤₣₧...") symbols and even one to type Greek letters (
"αβγδε...").