简体   繁体   English

jquery终端提交命令,无需按Enter键

[英]jquery terminal submit command without pressing enter

How can i submit a command without pressing the enter button? 如何在不按下回车键的情况下提交命令? I need to make the terminal recognize the speech (that part is already done) and visualize it like a command, than virtually press enter to get an ajax response, is it possible? 我需要让终端识别语音(该部分已经完成)并将其可视化为命令,而不是实际按Enter键获取ajax响应,是否可能? thanks 谢谢

push create new interpreter when you have new prompt and new set of commands, to execute the command you can use exec: 当你有新的提示和新的命令集时,push创建新的解释器,执行你可以使用exec的命令:

term.exec('command');

it will echo the command and execute your command (if you pass true as second argument it will not echo prompt and command being executed), for instancec if you have: 它将回显命令并执行您的命令(如果您传递true作为第二个参数,它将不会回显提示和正在执行的命令),例如,如果您有:

var term = $('...').terminal({
  foo: function() {
    this.echo('foo');
  }
});

term.exec('foo');

will execute your foo function. 将执行你的foo功能。

or you can simulate keydown event for enter: 或者您可以为enter模拟keydown事件:

var e = $.Event("keydown");
e.ctrlKey = ctrl;
e.altKey = alt;
e.shiftKey = shift;
e.which = e.keyCode = 13;
$(document.documentElement || window).trigger(e);

if you're adding text using term.insert('word'); 如果你使用term.insert('word');添加文本term.insert('word'); it will be better to use keydown event. 使用keydown事件会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM