I get ^[[D
with left arrow.
Ctrl-left gives ^[[151
in linux VC, and ^[[1;5D
in xterm
man keymaps
has:
Which of the actions bound to a given key is taken when it is pressed depends on what
modifiers are in effect at that moment. The keyboard driver supports 9 modifiers.
These modifiers are labeled (completely arbitrarily) Shift, AltGr, Control, Alt,
ShiftL, ShiftR, CtrlL, CtrlR and CapsShift. Each of these modifiers has an associated
weight of power of two according to the following table:
modifier weight
Shift 1
AltGr 2
Control 4
Alt 8
ShiftL 16
ShiftR 32
CtrlL 64
CtrlR 128
CapsShift 256
I changed it so both "Alt" keys do the same, like Shift and Control do:
Example: Keymaps-file for loadkeys
:
# three modifiers -> 8 cols. (AltGr missing):
#
keymaps 0-1,4-5,8-9,12-13
and then:
# left modifiers
keycode 42 = Shift
keycode 29 = Control
keycode 56 = Alt
keycode 58 = Caps_Lock
# right side...just Alt
keycode 54 = Shift
keycode 97 = Control
keycode 100 = Alt
Normally it is 100=AltGr.
Then I put two additional actions behind the default "Left":
keycode 105 = Left F150 F151
string F150 = "\033[150"
string F151 = "\033[151"
this has to be in two steps..."F150" is just a label to connect the modified key with a string.
Now I have my arrow key (105) producing "Left" as before, but shift and control produce the chosen escape sequences.
and then in ~/.inputrc
:
# Moving - modif. L+R Arrows in linux VC
# ascii codes in X / evdev / xterm
#
"\e[150": backward-word
"\e[1;2D": backward-word
"\e[154": forward-word
"\e[1;2C": forward-word
"\e[151": shell-backward-word
"\e[1;5D": shell-backward-word
"\e[155": shell-forward-word
"\e[1;5C": shell-forward-word
Looking back I should have chosen the 1;2D
that X produces. That would have saved some inputrc-lines. But these escape sequences seemed a bit opaque to me, so I defined my own ones.
To illustrate the modifier mapping:
# "Print Screen Sys Rq" is Nr 99
#
keycode 99 = F91 F92 F93 nul F95 F96
string F91 = " --help\n"
string F92 = " |less"
string F93 = " |grep "
string F95 = "()\033[D"
string F96 = "echo \'\033[4~\'"
Now I can hit formerly unused "Print" key to write --help
plus the Enter
. This works only in linux VC, because X also neglects my "Print" key and I have not found out how to activate it in XKB.
The "nul" entry is the place for "Shift+Control", which by weight comes before "Alt".
keymaps 0-1,4-5,8-9,12-13
: counting "0,1,4,5,8" puts weight "8" at fifth place, where "F95" is standing. "8" is defined as "Alt". The missing 2,3,6,7 are because I wanted to skip the AltGr-weight of value 2.
By combining say 10 F-keys with the 8 combinations of only Shift, Control and Alt (no left right) you can get 80 different key functions - if you want. But who wants Shift+Control-F6 to do one thing, and Control+Alt-F9 another?
/etc/default/keyboard
file KMAP variable is not defined, therefore I guess keymap is XKB layout (default value). – Anton Tolstov Mar 01 '20 at 04:35console-setup
to allow you to configure that. Have you tried that? – ILMostro_7 Mar 01 '20 at 04:49