Re: PC Keyboard question
The PC keyboard uses make/break or up/down codes. Each key has a unique scan code. When any key is pressed, the controller sends its scan code as a make- or down-code, and when the key is released the controller sends 0xf0 followed the same scan code as a two-byte break- or up-code.
If the A key has code 0x1f and B has code 0x32, and A is pressed, B pressed, A released, B released, the following sequence is sent:
0x1f A pressed
0x32 B pressed
0xf0 A released
0x1f
0xf0 B released
0x32
Notice that this description only mentions time in relation to when keys are pressed and released. The codes are sent when the controller detects the press and when the controller detects the release of each key individually.
When you press/release two (or more) keys near-simultaneously, the controller sends the codes in whatever order it wants (if you want them in a certain order then don't press them simultaneously!) but in reality it will send them in the order it scans the keys. Autorepeat will only happen on the key pressed 'last', i.e. the last key-down code sent will be repeated after the initial delay and then after the repeat delay, until that key is released or another key is pressed.
The shift, control, alt, etc. keys are treated identically to all the other keys, so they also generate auto-repeat codes, but of course you don't see that as a user because the repeat doesn't affect anything you see. Just like the other keys, pressing shift/control/alt/etc. also stops any existing autorepeat (e.g. press and hold A so it repeats then press shift, the repeat stops).