Spawned off bug 4971:
A very interesting corner case. This series of events can get the server confused:
1. AltL press
2. ShiftL press
3. AltL press
What is also needed is Alt_L like this in the keymap:
> keycode 64 = Alt_L Meta_L Alt_L Meta_L
> keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
(this is the default with the us keymap)
What will happen is that 1. will be sent as key 64, 2. as 50, and then 3. as key 204. At that point releasing Alt_L will only release key 204 and key 64 will remain wedged.
We need to check that a key isn't already in the pressed keys array and avoid the double allocation.
Shift-Alt is a bit special since it often sends Meta, so it got a special workaround upstream:
That might hide this bug for this specific scenario. The bug should be present for other keys with the same kind of mapping though.