By "internally" do you mean "in script" or "in the engine"?
Both, I guess? I seem to remember that there's a built-in function for just this in the latest betas, but meanwhile it should be doable in AGS script:
The two possible results I can think of for a keypress is that either a textbox is edited, or the
on_key_press() function is triggered. Am I overlooking anything else?
It shouldn't be difficult to trigger these same effects in a script (though if you have room-specific
on_key_press() functions, that might require some slight refactoring of the code). It's a little fiddly to determine whether any textbox is active and absorbing keypresses, but using the
guis[] and
GUI.Controls[] arrays along with
GUI.Visible,
GUIControl.AsTextBox,
GUIControl.Visible and
GUIControl.Enabled it's possible to do so.
this allows me to simulate a keypress without significant recoding of existing games.
I assume this is really the answer. Still, I'm pretty sure it would be possible to make an AGS script module that would do essentially the same as your plugin while requiring minimal changes to existing code, if that should ever become useful.