Xshell Forum

How do I send an ESC keypress?

Last post: Monday, November 16, 2015 10:12 PM by Support, 8 reply

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

How do I send an ESC keypress?

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

How do I send the ESC keypress?



Program Ver. : Xshell 4
Monday, May 14, 2012 5:12 PM - Zookeyan

Re: How do I send an ESC keypress?

 
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.
Monday, May 14, 2012 7:30 PM - Sean S

Re: How do I send an ESC keypress?

 
Thankyou!

I googled for ages trying to find the character code.
Sunday, October 25, 2015 12:27 PM - 1v

Re: How do I send an ESC keypress?

 
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));
}
Sunday, October 25, 2015 12:58 PM - 1v

Re: How do I send an ESC keypress?

 
And please make quick commands panel movable as other panels.
Tuesday, October 27, 2015 8:39 AM - zoo

Re: How do I send an ESC keypress?

 
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))
Tuesday, October 27, 2015 8:47 AM - Support

Re: How do I send an ESC keypress?

 
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
Friday, November 6, 2015 3:32 PM - 1v

Re: How do I send an ESC keypress?

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

Ok this work, but I can't find whole ASCII table of this codes.
Monday, November 16, 2015 10:12 PM - Support

Re: How do I send an ESC keypress?

 
^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