codemirror autocomplete after any keyup?

前端 未结 11 1485
忘了有多久
忘了有多久 2020-12-29 04:06

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 autocomple

11条回答
  •  感情败类
    2020-12-29 05:09

    changed Oleksandr Pshenychnyy's answer a little bit(see here), Answering as I can't add comments yet

    The code below only allows autocomplete to come up when a letter key is pressed (probably what you want instead on any key)

    editor.on("keyup", function (cm, event) {
    if (!cm.state.completionActive &&   /*Enables keyboard navigation in autocomplete list*/
         event.keyCode > 64 && event.keyCode < 91){// only when a letter key is pressed
             CodeMirror.commands.autocomplete(cm, null, {completeSingle: false});
        }
    });
    

    (this should work logically, but could some please comment if this works or not !)

提交回复
热议问题