I've always found konsole and bash keys/mode defaults to meet my needs with a few exceptions. Trying some commands brought up 3 questions. I'll stick to only 2 keys: up-key and key-pad up-key, but it could apply to all keys.
- My $TERM is equal to "xterm". "rxvt" came up a lot. Have you changed the value of TERM, and if so, to what and why?
- What command do you use to display the escape codes associated with keys?
- "\E[A" or "^[[A" are the same thing and I could have found that myself and created a keybinding. But how do I make the leap to "\EOA" for the key-pad up-key, since none of the commands below show it? Please see the commands and their output below.
If I typebind -q previous-history
, I get:
If I typeprevious-history can be invoked via "\C-p", "\eOA", "\e[A".sudo showkey
, and click the up-key and key-pad up-key, I get:
If I type^[[Akeycode 103 press
keycode 103 release
^[[Akeycode 72 press
keycode 72 releasexev
, and click the up-key and key-pad up-key, I get:
If I typekeycode 111 (keysym 0xff52, Up)
keycode 80 (keysym 0xff97, KP_Up)infocmp -L1 | less
, I can search for "\eOA", "\e[A" that was displayed by the first command.
I saw users use all kinds of command variations of sed, hexdump, cat to get the escape codes, but they all had the same results for both keys ("\e[A" or "^[[A").cursor_up=\E[A,
key_up=\EOA,
ncurses site talked about normal and an application mode for terminals, where the normal send escape sequence beginning with escape [ and the application mode escape O. The tldp also mentions these modes and says the keypad can be set to send special codes.... This would explain the two escape sequences. But how does the lowly user, just trying to create some key bindings, display escape codes in these modes....?
References:Numeric Keypad or Arrow Keys Sends
The numeric keypad (the rectangle of mostly numeric keys to the right of the main part of the keyboard) can be set to send special codes which will do special things in certain application programs. Ditto for the arrow keys. There is thus a "normal" mode where they send what is shown on the keycap (or the normal code sequence for an arrow-key) and an "application" mode where special escape sequences are sent. In some cases there is a "hex" numeric mode which is almost like normal numeric mode except that 6 non-numeric keys send the letters A-F. Thus one may type for example "B36F" on the numeric keypad.
This really isn't a Script question, maybe Bash, but rather hardware, readline, console, shell --- which is not necessarily bash...
Before posting, I searched for "key bindings" and similar messages have appeared in: Software & Applications, Cinnamon, Newbie Questions.
I had posted this item in "Other topics", but it seems to have been moved to this section.
It would really be helpful if the Linux Mint Forum moderators could mark these postings as moved to not only inform users but also educate, and hopefully decrease their workload in the future.