If the key completes a valid key sequence then queue the
        associated macro.

        |Args|

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

        |Returns|

        * **Bool**: **True** if there was at least a partial match and
                    **False** if the key sequence was invalid.

        |Raises|

        * **None**

def qteProcessKey(self, event, targetObj):
        """
        If the key completes a valid key sequence then queue the
        associated macro.

        |Args|

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

        |Returns|

        * **Bool**: **True** if there was at least a partial match and
                    **False** if the key sequence was invalid.

        |Raises|

        * **None**
        """
        # Announce the key and targeted Qtmacs widget.
        msgObj = QtmacsMessage((targetObj, event), None)
        msgObj.setSignalName('qtesigKeypressed')
        self.qteMain.qtesigKeypressed.emit(msgObj)

        # Ignore standalone <Shift>, <Ctrl>, <Win>, <Alt>, and <AltGr>
        # events.
        if event.key() in (QtCore.Qt.Key_Shift, QtCore.Qt.Key_Control,
                           QtCore.Qt.Key_Meta, QtCore.Qt.Key_Alt,
                           QtCore.Qt.Key_AltGr):
            return False

        # Add the latest key stroke to the current key sequence.
        self._keysequence.appendQKeyEvent(event)

        # Determine if the widget was registered with qteAddWidget
        isRegisteredWidget = hasattr(targetObj, '_qteAdmin')

        if isRegisteredWidget and hasattr(targetObj._qteAdmin, 'keyMap'):
            keyMap = targetObj._qteAdmin.keyMap
        else:
            keyMap = self.qteMain._qteGlobalKeyMapByReference()

        # See if there is a match with an entry from the key map of
        # the current object. If ``isPartialMatch`` is True then the
        # key sequence is potentially incomplete, but not invalid.
        # If ``macroName`` is not **None** then it is indeed complete.
        (macroName, isPartialMatch) = keyMap.match(self._keysequence)

        # Make a convenience copy of the key sequence.
        keyseq_copy = QtmacsKeysequence(self._keysequence)

        if isPartialMatch:
            # Reset the key combination history if a valid macro was
            # found so that the next key that arrives starts a new key
            # sequence.
            if macroName is None:
                # Report a partially completed key-sequence.
                msgObj = QtmacsMessage(keyseq_copy, None)
                msgObj.setSignalName('qtesigKeyseqPartial')
                self.qteMain.qtesigKeyseqPartial.emit(msgObj)
            else:
                # Execute the macro if requested.
                if self._qteFlagRunMacro:
                    self.qteMain.qteRunMacro(macroName, targetObj, keyseq_copy)

                # Announce that the key sequence lead to a valid macro.
                msgObj = QtmacsMessage((macroName, keyseq_copy), None)
                msgObj.setSignalName('qtesigKeyseqComplete')
                self.qteMain.qtesigKeyseqComplete.emit(msgObj)
                self._keysequence.reset()
        else:
            if isRegisteredWidget:
                # Announce (and log) that the key sequence is invalid. However,
                # format the key string to Html first, eg. "<ctrl>-x i" to
                # "<b>&lt;Ctrl&gt;+x i</b>".
                tmp = keyseq_copy.toString()
                tmp = tmp.replace('<', '&lt;')
                tmp = tmp.replace('>', '&gt;')
                msg = 'No macro is bound to <b>{}</b>.'.format(tmp)
                self.qteMain.qteLogger.warning(msg)
                msgObj = QtmacsMessage(keyseq_copy, None)
                msgObj.setSignalName('qtesigKeyseqInvalid')
                self.qteMain.qtesigKeyseqInvalid.emit(msgObj)
            else:
                # If we are in this branch then the widet is part of the
                # Qtmacs widget hierachy yet was not registered with
                # the qteAddWidget method. In this case use the QtDelivery
                # macro to pass on whatever the event was (assuming
                # macro processing is enabled).
                if self._qteFlagRunMacro:
                    self.qteMain.qteRunMacro(
                        self.QtDelivery, targetObj, keyseq_copy)
            self._keysequence.reset()

        # Announce that Qtmacs has processed another key event. The
        # outcome of this processing is communicated along with the
        # signal.
        msgObj = QtmacsMessage((targetObj, keyseq_copy, macroName), None)
        msgObj.setSignalName('qtesigKeyparsed')
        self.qteMain.qtesigKeyparsed.emit(msgObj)
        return isPartialMatch