How do I send an ESC keypress? [8]

How do I send an ESC keypress?

Sunday, May 13, 2012 11:49 PM - Sean S

I'm writing a script that does some editing in vi.

How do I send the ESC keypress?



Program Ver. : Xshell 4


Re: How do I send an ESC keypress?

Monday, May 14, 2012 5:12 PM - Zookeyan

Hi,
Apply this & own yours.

Sub Main
xsh.Screen.Send "vi hello.txt"
xsh.Screen.Send vbCr
xsh.Screen.Send "iHello World!"
xsh.Screen.Send chr(27)
xsh.Screen.Send ":wq"
xsh.Screen.Send vbCr
End Sub

The 'chr(27)' means ESC key.


Re: How do I send an ESC keypress?

Monday, May 14, 2012 7:30 PM - Sean S

Thankyou!

I googled for ages trying to find the character code.


Re: How do I send an ESC keypress?

Sunday, October 25, 2015 12:27 PM - 1v

But how to send key combination? For example I need ctrl+u - clear current line. Now I kinda spaming backspace:

function read(ScreenRow, Columns) {
return xsh.Screen.Get(ScreenRow, 1, ScreenRow, Columns).split("$").slice(-1)[0];
}

for (i = 1; i < Item.length; i++) {
if (read(ScreenRow, Columns) === " ")
break;
xsh.Screen.Send(String.fromCharCode(8));
}


Re: How do I send an ESC keypress?

Sunday, October 25, 2015 12:58 PM - 1v

And please make quick commands panel movable as other panels.


Re: How do I send an ESC keypress?

Tuesday, October 27, 2015 8:39 AM - zoo

When using a terminal, Terminal emulaters send a character or string of a key (including key combination), not key events.

So when Ctrl+U key pressed, ^U a character is sent to the server.
^U is the 21st character of the ASCII table.

If you make the character at your editor like vim, input the next script in your scrict file.
xsh.Screen.Send("^U")
else if you use js script
xsh.Screen.Send(String.fromCharCode(21))
else if vb script
xsh.Screen.Send(Chr(21))


Re: How do I send an ESC keypress?

Tuesday, October 27, 2015 8:47 AM - Support

Hi 1v ,

We will consider adding this feature in our next release.

Technical Support

Like us on Facebook
Follow us on Twitter
Visit our blog Blog


Re: How do I send an ESC keypress?

Friday, November 6, 2015 3:32 PM - 1v

xsh.Screen.Send(String.fromCharCode(21))

Ok this work, but I can't find whole ASCII table of this codes.


Re: How do I send an ESC keypress?

Monday, November 16, 2015 10:12 PM - Support

^C, ^U, and so on are considered caret notation.

You can find the whole list of characters here:
https://en.wikipedia.org/wiki/ASCII

Technical Support

Like us on Facebook
Follow us on Twitter
Visit our blog Blog


Previous views: 308