def keyPressEvent(self, event):
        if self.isReadOnly():
            return
        initial_state = event.isAccepted()
        event.ignore()
        self.key_pressed.emit(event)
        state = event.isAccepted()
        if not event.isAccepted():
            if event.key() == QtCore.Qt.Key_Tab and event.modifiers() == \
                    QtCore.Qt.NoModifier:
                self.indent()
                event.accept()
            elif event.key() == QtCore.Qt.Key_Backtab and \
                    event.modifiers() == QtCore.Qt.NoModifier:
                self.un_indent()
                event.accept()
            elif event.key() == QtCore.Qt.Key_Home and \
                    int(event.modifiers()) & QtCore.Qt.ControlModifier == 0:
                self._do_home_key(
                    event, int(event.modifiers()) & QtCore.Qt.ShiftModifier)
            if not event.isAccepted():
                event.setAccepted(initial_state)
                super(CodeEdit, self).keyPressEvent(event)
        new_state = event.isAccepted()
        event.setAccepted(state)
        self.post_key_pressed.emit(event)
        event.setAccepted(new_state)
Overrides the keyPressEvent to emit the key_pressed signal.
dataset/ETHPy150Open OpenCobolIDE/OpenCobolIDE/open_cobol_ide/extlibs/pyqode/core/api/code_edit.py/CodeEdit.keyPressEvent