For Ubuntu server version 18.04.3 Emacs does not recognize Alt and Shift keys the same way as the GUI. Emacs experts advised how to get the program to recognize those keys using escape sequences inputed into the emacs init file. But, I'm having trouble finding those escape sequences with the recommended methods:

Ctrl-q in emacs does not display escape sequences (not for me, at least, possible user error).

sed -n l plus Alt and Enter does not seem to work either.

Is there an Ubuntu-specific way of finding these escape sequences?


Inside emacs, Ctrl-H Ctrl-K keystroke will show you the key and what function is attached to the keystroke.

Ctrl-Q, in emacs, "quotes" the next character (removes any special meaning).

In bash Ctrl-V keystroke is useful, as:

echo "^vkeystroke" | od -bc

You could dump the character sequences with xev, part of the x11-utils package.

Read man terminfo;man tput and do something like (MY system, YMMV):

             # what's "clearscreen" for this terminal?
walt@bat:~(0)$ tput clear |od -bc
0000000 033 133 110 033 133 062 112
        033   [   H 033   [   2   J
             # That's ESCape, [, H, ESC [ 2 J
walt@bat:~(0)$ echo $TERM

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.