code: def on_state_changed(self, state):
          
          if state:
              self.editor.sig_key_pressed.connect(self._on_key_pressed)
          else:
              self.editor.sig_key_pressed.disconnect(self._on_key_pressed)
docs: Connect/disconnect sig_key_pressed signal.