title: Why keyPress Event in PyQt does not work for key Enter?
body: <p>Why, when I press <kbd>Enter</kbd>, does the <code>keyPressEvent</code> method not do what I need? It just moves the cursor to a new line.</p>
  
  <pre><code>class TextArea(QTextEdit):
      def __init__(self, parent):
          super().__init__(parent=parent)
          self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
          self.show()
  
      def SLOT_SendMsg(self):
          return lambda: self.get_and_send()
  
      def get_and_send(self):
          text = self.toPlainText()
          self.clear()
          get_connect(text)
  
      def keyPressEvent(self, event):
          if event.key() == QtCore.Qt.Key_Enter: 
              self.get_and_send()
          else:
              super().keyPressEvent(event)
  </code></pre>