The problem, which was not understood correctly by elexis here, and is that the hotkey state is changed in HotkeyInputHandler, so if that isn't run before handling the SDL_HOTKEYxxxx event, the state will be desynchronised.
There are still some cases where it is desynchronised though, namely all of "handleInputBeforeGUI" since that's called before the patch in rP19028 has any chance to trigger - and even then it's by sheer luck that it does.
I've looked at this some more as I needed handleInputBeforeGUI to have proper sync for D1837, and I believe the best fix is to add a new, top-priority handler in the event dispatch that does the state sync. This should ensure that our state is always synched, unless someone goes and change InitInput().
This thus completes rP14057.
Incidentally, I'm adding some simple tests for this that also show how to interact with JS code from C++ in a somewhat compact manner.
(I've had to change a number of other files to make the test actually test something).