def eventFilter(self, watched, event): if event.type() == QEvent.Type.KeyPress and event.matches( QKeySequence.StandardKey.InsertParagraphSeparator): self.return_pressed() return True else: return QWidget.eventFilter(self, watched, event)