code: def keyPressEvent(self, event):
          
          # emit the return pressed signal for this widget
          if event.key() in (Qt.Key_Return, Qt.Key_Enter) and \
             event.modifiers() == Qt.ControlModifier:
              self.acceptText()
              event.accept()
              return
          
          elif event.key() == Qt.Key_Tab:
              if self.tabsAsSpaces():
                  count = 4 - (self.textCursor().columnNumber() % 4)
                  self.insertPlainText(' ' * count)
                  event.accept()
                  return
          
          elif event.key() == Qt.Key_V and event.modifiers() == Qt.ControlModifier:
              self.paste()
              event.accept()
              return
          
          super(XTextEdit, self).keyPressEvent(event)
          
          if self.autoResizeToContents():
              self.resizeToContents()
docs: Processes user input when they enter a key.
          
          :param      event | <QKeyEvent>