Some keys does not work correctly in vterm if Emacs is in terminal mode

What happened?

When I open emacs in terminal mode (emacs -nw), some keys does not work properly in vterm. For example, if I hit DELETE, I receive a message saying that the buffer is read only. If I go to normal mode ant type ARROW UP to scroll, it goes to insert mode and it types OC in the command line. This behavior does not happen when Emacs is opened in GUI mode.

What did you expect to happen?

Typing DELETE should delete a character, and typing the arrows keys in normal mode should allow you to scroll the output.

Steps to reproduce

  1. emacs -nw
  2. Open vterm
  3. Type something and try to delete by pressing DELETE.
  4. Go to normal mode and press UP.

System information

Loading data dump...

I’m seeing similar behavior. @Ronis_BR Did you ever find a solution?

Hi @tabuchid !

I was not able to find a definite solution, but the code here helped a lot:

AFAIK those are related to the inherent limitations of the TTY/terminal Emacs, they can’t recognize all key strokes like a graphical shell can.

While I don’t know how to workaround the arrow keys, the DELETE key can be recognized in vterm inside terminal Emacs by:

(map! :map vterm-mode-map "<deletechar>" #'vterm-send-delete)

as GUI Emacs receives “<delete>” for the DELETE key and “<deletechar>” in a terminal session, but vterm-mode-map only binds the former.