environment/lib/python2.7/site-packages/IPython/frontend/qt/console/completion_widget.py
def eventFilter(self, obj, event):
        """ Reimplemented to handle keyboard input and to auto-hide when the
            text edit loses focus.
        """
        if obj == self._text_edit:
            etype = event.type()

            if etype == QtCore.QEvent.KeyPress:
                key, text = event.key(), event.text()
                if key in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter,
                           QtCore.Qt.Key_Tab):
                    self._complete_current()
                    return True
                elif key == QtCore.Qt.Key_Escape:
                    self.hide()
                    return True
                elif key in (QtCore.Qt.Key_Up, QtCore.Qt.Key_Down,
                             QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown,
                             QtCore.Qt.Key_Home, QtCore.Qt.Key_End):
                    self.keyPressEvent(event)
                    return True

            elif etype == QtCore.QEvent.FocusOut:
                self.hide()

        return super(CompletionWidget, self).eventFilter(obj, event)
def eventFilter(self, obj, event):
        """ Reimplemented to handle keyboard input and to auto-hide when the
            text edit loses focus.
        """
        if obj == self._text_edit:
            etype = event.type()

            if etype == QtCore.QEvent.KeyPress:
                key, text = event.key(), event.text()
                if key in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter,
                           QtCore.Qt.Key_Tab):
                    self._complete_current()
                    return True
                elif key == QtCore.Qt.Key_Escape:
                    self.hide()
                    return True
                elif key in (QtCore.Qt.Key_Up, QtCore.Qt.Key_Down,
                             QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown,
                             QtCore.Qt.Key_Home, QtCore.Qt.Key_End):
                    self.keyPressEvent(event)
                    return True

            elif etype == QtCore.QEvent.FocusOut:
                self.hide()

        return super(CompletionWidget, self).eventFilter(obj, event)
Reimplemented to handle keyboard input and to auto-hide when the
            text edit loses focus.