Comment by akira2501

Comment by akira2501 3 days ago

1 reply

> The timing required is strict.

Your keyboard has a serial interface to your computer. Events are generated serially. If you press one first it will register first.

> keystrokes are generated by their up events

We don't do this because then you can't have auto repeat.

kazinator 3 days ago

> If you press one first it will register first.

While that is obviously so, there are two events: a press and a release event.

The thing I run into is that the release time: Shift being held over too long, into the start of the next character. Now comes out as NOw because the up event for Shift comes after the down event for w.

So I don't think my proposals are necessarily the right ones.

Perhaps this: when a shifted letter is being typed (the down event came in a shifted state), then the rule should apply that an up event should be received to generate the keystroke, and that up event should still be in the shifted state.

Refinement: when a shifted letter is being typed in a situation where the Shift was held over from a previous shifted letter, then apply the logic. Thus N is not delayed; it comes out on the downstroke. But if Shift is still held while o is typed, that is a held-over Shift, and so the rule applies; the state machine must see an up event for the o and then decides whether it is shifted. If Shift is released before the o, then o is issued on the down event as usual.

Another idea: when a shifted letter is being typed in a Shift-holdover state, then issue the keystroke for the letter either on the release of the Shift, or the release of the letter, whichever comes first. If Shift is released first, assume it was a holdover and don't capitalize the keystroke. If the letter is released first, issue the capitalized keystroke. In the situation where the intent is to type Now, this will hardly result in a noticeable delay for the o, since the Shift hold-over period is very brief.

> you can't have auto-repeat

Auto-repeat is an arbitrary behavior that kicks in due to a timer going off while a key is continuously held down.

It generates multiple fake keystrokes even though there aren't multiple down events.

So of course you can still have it generate multiple keystrokes even though there aren't multiple up events (including generating the first keystroke in spite of there not being any up event).