任何密钥后的codemirror自动完成? [英] codemirror autocomplete after any keyup?
问题描述
我正在尝试添加自定义自动填充功能,我想在用户输入时触发(当然可配置)。我找到了几个代码镜像自动完成的例子:
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 和
http ://codemirror.net/demo/xmlcomplete.html
但这两个触发器都在特定键上触发(Control-Space为1和'<'对于另一个)并且都使用 extraKeys
功能来处理事件,但我想从任何键触发。我尝试了以下内容:
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?
推荐答案
onKeyEvent: function(e , s){
if (s.type == "keyup")
{
console.log("test");
}
}
这篇关于任何密钥后的codemirror自动完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!