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...