How to listen to keydown events from a CodeMirror content script?

I've been trying to get a simple CodeMirror content script working to test a few things, but couldn't get it to work.

I would like to listen to the "keydown" event on the editor, so that I do some action when for example the "x" key is pressed. However the plugin only gets the "CodeMirror" class as input, on which it's not possible to add this event handler.

So I'm wondering what's the way to grab a CodeMirror instance and add event handlers? Or are there other ways to do this?

This works for me:

	CodeMirror.defineOption('inlineTags', [], function(cm, value, prev) {
        cm.on('inputRead', function (cm1, change) {
            if (change.text[0] === '#') {

Yes thank you, that works for me too.