docs: def key_press_event(self, event):
          """
          Manages our own buffer and send it to the subprocess when user pressed RETURN.
          """
          input_buffer = self._get_input_buffer()
          ctrl = int(event.modifiers() & QtCore.Qt.ControlModifier) != 0
          shift = int(event.modifiers() & QtCore.Qt.ShiftModifier) != 0
          delete = event.key() in [QtCore.Qt.Key_Backspace, QtCore.Qt.Key_Delete]
          ignore = False
          if delete and not input_buffer and not shift:
              return False
          if ctrl:
              if shift and event.key() == QtCore.Qt.Key_V:
                  self.edit.insertPlainText(QtWidgets.qApp.clipboard().text())
                  return False
              elif event.key() == QtCore.Qt.Key_L:
                  self.edit.clear()
                  if sys.platform == 'win32':
                      self.process.write(b'\r')
                  self.process.write(b'\n')
                  return False
          if (shift or ctrl) and event.key() == QtCore.Qt.Key_Backspace:
              if input_buffer.strip() != '':
                  return True
              self._clear_user_buffer()
              return False
          if event.key() == QtCore.Qt.Key_Up:
              if self.is_code_completion_popup_visible():
                  return True
              self._insert_command(self._history.scroll_up())
              return False
          if event.key() == QtCore.Qt.Key_Left:
              return bool(input_buffer)
          if event.key() == QtCore.Qt.Key_Down:
              if self.is_code_completion_popup_visible():
                  return True
              self._insert_command(self._history.scroll_down())
              return False
          if event.key() == QtCore.Qt.Key_Home:
              tc = self.edit.textCursor()
              tc.movePosition(tc.StartOfBlock)
              tc.movePosition(tc.Right, tc.MoveAnchor, self.edit._formatter._prefix_len)
              self.edit.setTextCursor(tc)
              return False
          if event.key() == QtCore.Qt.Key_End:
              tc = self.edit.textCursor()
              tc.movePosition(tc.EndOfBlock)
              self.edit.setTextCursor(tc)
              self._cursor_pos = len(self._get_input_buffer())
              return False
          if event.key() in [QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter]:
              if self.is_code_completion_popup_visible():
                  return True
              tc = self.edit.textCursor()
              tc.movePosition(tc.EndOfBlock)
              self.edit.setTextCursor(tc)
              # send the user input to the child process
              if self.edit.flg_use_pty or 'cmd.exe' in self.process.program():
                  # remove user buffer from text edit, the content of the buffer will be
                  # drawn as soon as we write it to the process stdin
                  tc = self.edit.textCursor()
                  for _ in input_buffer:
                      tc.deletePreviousChar()
                  self.edit.setTextCursor(tc)
              self._history.add_command(input_buffer)
              if sys.platform == 'win32':
                  input_buffer += "\r"
              input_buffer += "\n"
              self.process.write(input_buffer.encode())
              if self.edit.flg_use_pty or 'cmd.exe' in self.process.program():
                  ignore = True
          return not ignore