Intercept keyboard events and pass them on to the key parser
        and/or applet and/or widget.

        The handler only intercepts keyboard events and lets Qt handle
        the remaining ones (eg. mouse clicks) as usual.

        |Args|

        * ``targetObj`` (**QObject**): the source of the event (see Qt
          documentation).
        * ``event_qt`` (**QEvent**): information about the event (see Qt
          documentation).

        |Returns|

        * **bool**: if **True**, Qt will consider the event handled.

        |Raises|

        * **None**

def eventFilter(self, targetObj, event_qt):
        """
        Intercept keyboard events and pass them on to the key parser
        and/or applet and/or widget.

        The handler only intercepts keyboard events and lets Qt handle
        the remaining ones (eg. mouse clicks) as usual.

        |Args|

        * ``targetObj`` (**QObject**): the source of the event (see Qt
          documentation).
        * ``event_qt`` (**QEvent**): information about the event (see Qt
          documentation).

        |Returns|

        * **bool**: if **True**, Qt will consider the event handled.

        |Raises|

        * **None**
        """
        # Return immediately if Qtmacs is not interested in it.
        if event_qt.type() not in self.qteEventList:
            return False

        # Determine if the widget belongs to the Qtmacs hierarchy and
        # return immediately if not.
        if not qteIsQtmacsWidget(targetObj):
            return False

        # If the event is a mouse click then update the Qtmacs internal
        # focus state and tell the Qt library that the event was NOT
        # handled. This ensures the click is propagated to the widget.
        if event_qt.type() == QtCore.QEvent.MouseButtonPress:
            self.qteMain._qteMouseClicked(targetObj)
            return False

        # Make a copy of the QKeyEvent because Qt will delete the
        # underlying object as soon as the event is handled. However, some
        # macros might retain a reference which will then become invalid
        # and result in a difficult to trace bug. Therefore, supply them
        # with an explicit copy only.
        event = QtGui.QKeyEvent(event_qt.type(), event_qt.key(),
                                event_qt.modifiers(), event_qt.text(),
                                event_qt.isAutoRepeat(), event_qt.count())

        # Abort the input if the user presses <ctrl>-g and declare the
        # keyboard event handled.
        mod = event.modifiers()
        key = event.key()
        if (mod == QtCore.Qt.ControlModifier) and (key == QtCore.Qt.Key_G):
            # Furthermore, clear the key sequence and ensure macro execution
            # is turned on again.
            self._keysequence.reset()
            self._qteFlagRunMacro = True

            # Remove the mini applet.
            self.qteMain.qteKillMiniApplet()

            # Drop all macros and keys left in the respective queues.
            self.qteMain._qteMacroQueue = []
            self.qteMain._qteKeyEmulationQueue = []

            # Ensure the focus manager runs once the event loop is idle again.
            # Also, emit the abort signal.
            msgObj = QtmacsMessage()
            msgObj.setSignalName('qtesigAbort')
            self.qteMain.qtesigAbort.emit(msgObj)
            return True

        # If the widget is unregistered then parse the key without further
        # ado and declare the key event handled via the return value.
        if not hasattr(targetObj, '_qteAdmin'):
            self.qteProcessKey(event, targetObj)
            return True

        # Shorthand to the QtmacsApplet that received this event.
        qteApplet = targetObj._qteAdmin.qteApplet

        # Retrieve information about how the widget wants its keyboard
        # events processed.
        tmp = targetObj._qteAdmin.keyFilterPolicy()
        receiveBefore, useQtmacs, receiveAfter = tmp
        del tmp

        # If the applet requested the keyboard input before being
        # processed by Qtmacs then send the event to the applet which
        # harbours the object (ie. *NOT* the object itself). It is the
        # responsibility of the applet to enact the desired
        # behaviour. If this action is the native behaviour of the
        # widget then the applet should consider using
        # "self.qteText.keyPressEvent(keyEvent)" to achieve this.
        if receiveBefore:
            qteApplet.qteKeyPressEventBefore(event, targetObj)

        # If the applet wants Qtmacs to process the keyboard event then do so.
        if useQtmacs:
            self.qteProcessKey(event, targetObj)

        # If the applet requested the keyboard input after being
        # processed by Qtmacs then send the event to the applet which
        # harbours the object (ie. *NOT* the object itself). It is the
        # responsibility of the applet to enact the desired behaviour
        # on the object.
        if receiveAfter:
            qteApplet.qteKeyPressEventAfter(event, targetObj)

        # Declare the key event handled.
        return True