Processing of keypress events occurs at the kernel level, which transmits the scancode to the terminal device. We need a module for the kernel that corrects key scancodes for utf8, I don’t know which one, if anyone knows, please tell me.
P.S. Wrong scan code from keyboard to tty (pts), output from tty (pts) to tty (pts), everything is fine.