This is possible if and only if the terminal sends different escape sequences for Ctrl+Left vs Left. This is not the case by default on the Linux console (at least on my machine). You can make it so by modifying the keymap. The exact file to modify may depend on your distribution; on Debian lenny, the file to modify is /etc/console/boottime.kmap.gz
. You need lines like
control keycode 105 = F100
string F100 = "\033O5D"
control keycode 106 = F101
string F101 = "\033O5C"
You might as well choose the same escape sequences as your X terminal emulator. To find out what the control sequence is, type Ctrl+V Ctrl+Left in a shell; this inserts (on my machine) ^[O5D
where ^[
is an escape character. In the keymap file, \033
represents an escape character.
Configuring the application in the terminal to decode the escape sequence is a separate problem, .
"\033O5D"
code, but completely omitting where you got thekeycode 105
andF100
codes from. Besides, I get^[[1;5B
and^[[1;5A
for ctrl+Down and Ctrl+Up. How should I handle the1;
part? – Martin Vegter Apr 20 '16 at 10:08showkey
program. The1;
part isn't different from the rest:"\033[1;5B"
and so on. – Gilles 'SO- stop being evil' Apr 20 '16 at 10:29keycode 105
can be found usingshowkey
. But where did you get theF100
? – Martin Vegter Apr 20 '16 at 10:44