Search code examples
javascriptace-editor

Keydown event on Ace Editor


On this amazing editor (Ace: Code Editor), there's a method which I can get the on change event, is there a on keydown event? Or a hack I can simulate it?


Solution

  • 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