run a code with click event

I want to run a code when click event, Is there an easy way to do it?

Add the result of EditorView.domEventHandlers to your state configuration.