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?
Download CodeMirror files. Download jQuery file. Inside the codemirror project folder create subfolders and name them js, css and plugin. The js folder will hold all the javascript files.
CodeMirror uses a concept of operations, which start by calling a specific set-up function that clears the state and end by calling another function that reads this state and does the required updating. Most event handlers, and all the user-visible methods that change state are wrapped like this.
To get the value of the CodeMirror text editor we need to write some javascript code in the default. js file. $(document). ready(function(){ //code here...
CodeMirror is a code-editor component that can be embedded in Web pages. The core library provides only the editor component, no accompanying buttons, auto-completion, or other IDE functionality. It does provide a rich API on top of which such functionality can be straightforwardly implemented.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With