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
Asked
Active
Viewed 515 times
1
-
`$( "target" ).click()`? – almanegra Jun 10 '16 at 01:01
-
Hello almanegra, actually i need a command to execute without clicking but calling a function in jquery terminal. – Robert Falco Jun 10 '16 at 11:34
-
I believe there is a native command like "push", but i don't know how to use it. This is the reference http://terminal.jcubic.pl/api_reference.php there are just a few examples. – Robert Falco Jun 10 '16 at 11:38
1 Answers
0
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 key down event.
EDIT: key down event may not work with a recent version of jQuery Terminal to trigger the event with jQuery events look at Jest tests.

jcubic
- 61,973
- 54
- 229
- 402