When I press AltUp,
A printed to terminal screen. Same thing happened when I pressed AltDown but
B is printed instead.
Other characters that I realized;
D and AltRight =
What is the purpose of these commands?
Depending on how the terminal is configured, typing Alt+Key is like typing the Esc and Key keys in sequence, so it sends the ESC character (aka
Upon pressing Up, most terminal emulators send either the three characters
The first one does correspond to the escape sequence which when output to the terminal, move the cursor up. If you do:
You'll see that the arrow keys do move the cursor around.
When an application like
Now, for Alt-Up, some terminals like
Those will typically send
When sent to the terminal, that sequence will also move the cursor up (the second parameter (3) is ignored). There's no corresponding keypad key, so it's the same sequence sent upon Alt-Up in or out of application keypad mode.
Now whether it's
They will try their best to interpret that sequence.
Many applications like
For instance, in
Those are to search the history backward and forward for command lines that start like the current one up to the current position of the cursor which is quite handy to recall previous commands.
You can use Crtl+v to return input codes of your keyboard. If you do that for arrow keys, you will get
And add a line:
Instead text you can pass a bindable command from http://www.gnu.org/software/bash/manual/html_node/Bindable-Readline-Commands.html#Bindable-Readline-Commands like
to have same effect like Crtl+u (delete line).
More information here: http://cnswww.cns.cwru.edu/php/chet/readline/readline.html
The Alt key is often used as a meta modifier. Cursor- and function-keys are referred to as special keys since they may send multiple characters — and the characters which are sent can be altered.
Some users, e.g., for
Other users (since
suggests that the application move the cursor up 5 rows, while
suggests that it move up one row, telling the application that a control key was pressed.
The useful combinations have been in the ncurses terminfo database since 2004:
The terminfo database shows the current version of xterm+pcfkeys with a comment showing how the modifiers are encoded:
(Alt and meta are not necessarily the same key). That is a building block (in turn composed of other building blocks) from which the
Now comes a difficulty: there are a few ways for an application to determine what a key sequence like that represents:
Few programs would do the first; some text editors would do the second (actually, I did this for
Since none of the strings that