Originally Posted by Golden Child
This function actually first "presses" all of the fields for a given keycode, then it releases them one by one each time it gets called after that. It seems really counter-intuitive. One of the things that really threw me for a loop is that it does things "reversed" like field->set_value(!m_status_keydown). m_status_keydown comes in as false, it sets all the fields, then it flips the m_status_keydown.

You've missed some of the subtlety - it presses the keys one-at-a-time with a delay between each to ensure there's time for matrix scanning to detect the modifiers before the character key is pressed. Without this, uppercase letters, shifted numbers etc. don't work on Amiga, Sun, RM Nimbus, and a host of other systems (I implemented this myself after over a year of complaints about it not working but none of the natural keyboard advocates addressing it). However it releases all the emulated keys at the same time - it doesn't wait for the timer to fire between releasing keys.

Yes, it's "dumb" in cases where a sequence of shifted keys are typed in a row - it presses and releases shift for each one - but making it "smarter" about this would complicated the code quite a bit.

The trouble with adding a delay on CR is it's going to be a real pain for actually typing into a text editor, and even at a command prompt, different commands all take different amounts of time.