tty.js icon indicating copy to clipboard operation
tty.js copied to clipboard

Howto inject external data in the terminal

Open ysagon opened this issue 12 years ago • 3 comments

Hello,

I was wondering what would be the best solution to inject data in the terminal not typed by the user.

What I mean is the following: I want to have some data (text) "typed" in the terminal in a programatic way. To achieve that is it better to do some javascript and write text in the terminal window (simulate a typing)? Or maybe directly write on the websocket (clientside)? Or something else?

Thanks for any ideas!

ysagon avatar Apr 25 '13 20:04 ysagon

:thumbsup: I am also interested in this.

vincentwoo avatar Sep 08 '13 22:09 vincentwoo

Just simulate keydown events. For example, to send "abcd":

var codes = [5,6,7,8];
for(var i = 0; i<codes.length; i++) {
  Terminal.focus.keyDown({keyCode: 60 + codes[i]});
}

nuex avatar Sep 09 '13 01:09 nuex

If I want to simulate a certain keydown event after the terminal are created. where I should put the code?

cettco avatar Dec 03 '14 07:12 cettco