'Override keyPressEvent to handle special keypresses.'

def keyPressEvent(self, e):

    if (e.key() == Qt.Key_Up):
        self.history_prev()
        e.accept()
    elif (e.key() == Qt.Key_Down):
        self.history_next()
        e.accept()
    elif ((e.modifiers() & Qt.ControlModifier) and (e.key() == Qt.Key_C)):
        self.setText('')
        e.accept()
    else:
        super().keyPressEvent(e)
