This question is inspired by another question on vi.SE. There, OP has issues with the Shift+F8 key combination when running vim
inside urxvt
. That key combination will never work in vim
because the terminal emulator does not pass it correctly (at least from what I managed to debug).
I do not have a good understanding on how the F
keys are handled by terminal emulators.
In urxvt
- When I press Shift+F8
~
is echoed. - When I press F7 (or any other F key)
~
is echoed as well.
In vim
inside urxvt
- When I press Shift+F8 I get the effect of
~~
. - When I press Shift+F7 I get the effect of
~
. - When I press Shift+F6 I get the effect of
~~~
.
In xterm
on the other hand:
- When I press Shift+F8
;2~
is echoed. - When I press F8 (or any other F key) only
~
is echoed.
I am at a loss in understanding why I get this output.
To debug further I did run xev
and got the following:
For F8
KeyPress event, serial 29, synthetic NO, window 0x2000001,
root 0x7e, subw 0x0, time 17730758, (431,256), root:(432,275),
state 0x0, keycode 74 (keysym 0xffc5, F8), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
For left Shift
KeyPress event, serial 32, synthetic NO, window 0x2000001,
root 0x7e, subw 0x0, time 17733031, (431,256), root:(432,275),
state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
And for right Shift
KeyPress event, serial 32, synthetic NO, window 0x2000001,
root 0x7e, subw 0x0, time 17733372, (431,256), root:(432,275),
state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
Yet, I see absolutely nothing strange in there.
How these keys (the F keys) are treated by terminal emulators? What do terminal emulators receive from x11
? And how they pass it further to the program running inside them?
I always believed that the F keys were just a combination of Esc plus a digit. Now I found I was wrong.
Addendum
The F keys without Shift work well in vim
inside urxvt
. If I do:
:map <f8> :echo "yay"<CR>
I do correctly get the "yay" echoed out when I press F8.
G
. no privision is made forshift
,ctrl
,alt
, etc. + func. – Jasen Jun 28 '16 at 01:11FNK
control sequences.DECFNK
is common, but as M. Dickey says, there's a wide degree of variability. – JdeBP Jun 28 '16 at 08:03tmux
. I can replicate this by simply settingTERM=rxvt-unicode-256color
– grochmal Jun 28 '16 at 13:36