简体   繁体   中英

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? thanks

push create new interpreter when you have new prompt and new set of commands, to execute the command you can use 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:

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

term.exec('foo');

will execute your foo function.

or you can simulate keydown event for enter:

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'); it will be better to use keydown event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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