Adding a handleKeyUp handler

I am using proseMirror inside a webpage I have no control over and I need to capture the keyUp event to avoid propagation. I have seen only handleKeyUp and HandleKeypress entries in the plugin documentation…

Could you provide guidance on how to add this ?

thanks in advance !!

If you don’t have control over the editor instance, I’d say the most straightforward approach is to just add plain DOM handlers that call stopPropagation on the events.

thank you so much for your quick answer ! I have control over the editor instance. Let me give you a bit more of context: I am creating proseMirror instances from a chrome extension. Some keystrokes are creating interferences with the current webpage.

  • I have been able to insert keyPress and keyDown handlers thru the plugin which are taking precedence and stopping propagation
  • however the webpage is also listening for keyUp events and I have not seen a simple way to specify a keyUp handler in the options. Maybe I missed something …

Use handleDOMEvents to attach arbitrary DOM handlers. You might want to also do that for keydown and keypress, since it’s simpler.

thank you! meantime I successfully have added some event handler as this: editor.ref.current.addEventListener(“keyup”,handleKey)