code: def keyPressEvent(self, ev):
          
          if ev.key() in (Qt.Key_Shift, Qt.Key_Control,
                          Qt.Key_Meta, Qt.Key_Alt,
                          Qt.Key_AltGr, Qt.Key_CapsLock,
                          Qt.Key_NumLock, Qt.Key_ScrollLock):
              return False  # ignore modifier pressing. Will process key pressing later
  
          self._processingKeyPress = True
          try:
              ret = self._mode.keyPressEvent(ev)
          finally:
              self._processingKeyPress = False
          return ret
docs: Check the event. Return True if processed and False otherwise