# Adding a handleKeyUp handler

**URL:** <https://discuss.prosemirror.net/t/adding-a-handlekeyup-handler/4001>\
**Category:** Uncategorized\
**Created:** [August 26, 2021, 1:36pm UTC](https://discuss.prosemirror.net/t/adding-a-handlekeyup-handler/4001 "2021-08-26T13:36:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jml674](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/90ced4/32.png) [@jml674](https://discuss.prosemirror.net/u/jml674)\
**Post date:** [August 26, 2021, 1:36pm UTC](https://discuss.prosemirror.net/t/adding-a-handlekeyup-handler/4001/1 "2021-08-26T13:36:28Z")

</div>

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 !!

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [August 26, 2021, 1:57pm UTC](https://discuss.prosemirror.net/t/adding-a-handlekeyup-handler/4001/2 "2021-08-26T13:57:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jml674](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/90ced4/32.png) [@jml674](https://discuss.prosemirror.net/u/jml674)\
**Post date:** [August 26, 2021, 3:47pm UTC](https://discuss.prosemirror.net/t/adding-a-handlekeyup-handler/4001/3 "2021-08-26T15:47:25Z")

</div>

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 …

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [August 26, 2021, 4:14pm UTC](https://discuss.prosemirror.net/t/adding-a-handlekeyup-handler/4001/4 "2021-08-26T16:14:08Z")

</div>

Use [`handleDOMEvents`](https://prosemirror.net/docs/ref/#view.EditorProps.handleDOMEvents) to attach arbitrary DOM handlers. You might want to also do that for keydown and keypress, since it’s simpler.

---

<div class="post-metadata">

**Author:** ![jml674](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/j/90ced4/32.png) [@jml674](https://discuss.prosemirror.net/u/jml674)\
**Post date:** [August 26, 2021, 4:23pm UTC](https://discuss.prosemirror.net/t/adding-a-handlekeyup-handler/4001/5 "2021-08-26T16:23:59Z")

</div>

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