I'm working on trying to add a custom autocomplete, that I want to trigger whenever the user is typing (configurable of course). I've found a couple examples of autocomplete for codemirror:
http://codemirror.net/demo/complete.html and http://codemirror.net/demo/xmlcomplete.html
But both of these trigger on specific keys (Control-Space for one and '<' for the other) and both use the extraKeys
functionality to process the events, but I want to trigger from any key. I have tried the following:
var editor = CodeMirror.fromTextArea(document.getElementById("code"),
{
lineNumbers: true,
mode: "text/x-mysql",
fixedGutter: true,
gutter: true,
// extraKeys: {"'.'": "autocomplete"}
keyup: function(e)
{
console.log('testing');
},
onkeyup: function(e)
{
console.log('testing2');
}
});
But have had no luck. Any suggestions on how I could trigger from any keyup events?
NOTE: This answer does not work on recent versions of CodeMirror.
onKeyEvent: function(e , s){
if (s.type == "keyup")
{
console.log("test");
}
}