I believe that you should use StyledTextCtrl events for handling events in a StyledTextCtrl, not wx events.
The most obvious event to handle would seem to be EVT_STC_KEY
. However, according to the documentation for the event, this might not work:
The Scintilla documentation says:
Reports all keys pressed. Used on GTK+ because of some problems with keyboard focus. Not sent by Windows version.
As far as this writer can tell, this means that this event, although technically available thru wxWindows, will not actually ever occur.
You can try handling the EVT_STC_CHARADDED
event instead, but that seems to be called after a new line has been added. Calling event.Skip()
for this event has no effect. On Windows, this event fires twice, once for the carriage-return \r
and once for the newline \n
.
Ultimately, it's possible that what you are trying to achieve might not be possible.
(Incidentally, STC_KEY_DOWN
is a code that represents the down-arrow key, not that a key has been pressed down.)