Key events with closebrackets

I am developing a plugin for Obsidian.md, which relies on a CM6 editor. my plugin uses an editor extension to react to key strokes. Any event with type of “input.type” is processed, then inserted.text[0] is checked for the typed character.

This works great, except for when typing over auto-entered characters, such as when using the “closebrackets” extension. This includes things like hitting the quote key to close a quote. The closing quote character was auto-entered, beyond the caret, when the opening quote was typed. Typing the closing quote simply moves the caret past the auto-entered closing quote. In cases of typing past auto-entered characters like this, the editor extension still gets an event, but that event has no identifying type, or indication as to what key was typed.

Does anyone know of a way around this? I mean, to react properly to keys that are typed, including those that simply shift the caret past auto-entered characters?

What are you doing in response to the keystrokes? Would using a keydown DOM event handler work?

The plugin is a text expander. In response to a particular keystroke (semicolon by default) I am capturing text prior to the caret, and if it matches a specific regex then I am replacing the text with the result of a user-defined javascript function.
I haven’t considered bypassing the codemirror system by trying a keydown DOM event handler. I’ll see if I can get that working.

Sounds like you might also just be able to bind ‘;’ with a keymap in this case.