Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I send arrow key presses to a process using Expect.pm

Tags:

Seems like this should be obvious, but how do I send arrow key presses to a process using Expect.pm? Does it depend on the terminal type I am using (vt100) or do I send keyboard scancodes?

TIA.

like image 944
Anon Gordon Avatar asked Oct 18 '09 09:10

Anon Gordon


People also ask

How do you send an arrow key in Autohotkey?

If you want to send a special key like the right arrow button or the return/enter key, you would have to enclose it in curly braces {} . For example, {right} or {return} corresponding to the aforementioned examples. For more information about this, please see this documentation link.

How do you press the arrow keys?

For smaller keyboards and many laptop keyboards, the arrow keys may be moved below Enter and the right Shift . Also, some compact keyboards may move the arrow keys to the keypad and switch between the keypad and arrow keys by pressing the Num Lock key.

How do you use arrow keys in coding?

To detect the arrow key when it is pressed, use onkeydown in JavaScript. The button has key code. As you know the left arrow key has the code 37. The up arrow key has the code 38 and right has the 39 and down has 40.

What button is arrow key?

Arrow keys are typically located at the bottom of the keyboard to the left side of the numeric keypad, usually arranged in an inverted-T layout but also found in diamond shapes and linear shapes. Arrow keys are commonly used for navigating around documents and for playing games.


1 Answers

It does indeed depend on your current TERM environment variable. Once that's set correctly (say VT220 or linux), then arrow keys are

up:    "\c[[A"
down:  "\c[[B"
left:  "\c[[D"
right: "\c[[C"
like image 85
Jonathan Feinberg Avatar answered Oct 05 '22 13:10

Jonathan Feinberg