Search code examples
codemirrorkeymaps

How to add custom key maps in CodeMirror?


I want add 'Alt-Space' key map to codemirror and then perform a particular function when the keys are pressed. I am not able to add this keymap using .

cm.addKeyMap

Where should I be writing this function so that the key map can be bound to a particular function?


Solution

  • What is the exact code you are using?

    For your information, you can always add any keyMap to the editor instance by the following lines of code :

    var map = {"Alt-Space": function(cm){...}}
    editor.addKeyMap(map);
    

    where, editor is the CodeMirror instance.