Keydown event on Ace Editor

There is no keydown event, you can add keydown event listener on textarea returned by editor.textInput.getElement(), but the better way is to use editor.commands.addCommand

editor.commands.addCommand({
    name: "...",
    exec: function() {},
    bindKey: {mac: "cmd-f", win: "ctrl-f"}
})

or editor.keyBinding.addKeyboardHandler


I can't find it in the documentation, but in this discussion, I found out about the editor.commands.on('afterExec', ...) API:

editor.commands.on('afterExec', eventData => {
    if (eventData.command.name === 'insertstring') {
        console.log('User typed a character: ' + eventData.args);
    }
});

afterExec fires on every command in the editor. Commands include actions like typed text, appearance of completion popups on ctrl+space, etc...

It's not a direct analog of keydown event, but it is the thing I was googling for when I came here, so hopefully you'll find it useful.