How to add custom key maps in CodeMirror?

6.2k Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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.