overwrite click events

i want to change the functionality of ctrl+click.

right now, i managed to create an extension that triggers a function if i press ctrl and then click the right mouse button. However codemirror already has a functionality (adding an additional cursor at mouse position) that also triggers.

how is it possible to prevent the default event from triggering?

i tried to do it with the keymaps but click events are not part of the keymaps

CodeMirror’s mouse handling happens in mousedown/mousemove/mouseup handlers. If you override mousedown and call preventDefault (or return true from a handler registered through the library), that should prevent the default response.

This is what i have right now. but it does not prevent the default action. Do i have to register the events differently?

export let myCtrlClickExtension = EditorView.domEventHandlers({
  click: (event, view) => {
    if (event.ctrlKey) {
      event.preventDefault()
      // dostuff
    }
  },
});

You’re handling click. I suggested you handle keydown. And return true from the handler.

you were refering to ‘mousedown’, now it works, thank you. i mistakenly thought the event was triggered on ‘click’