Persist currently edited note annotation text

Q: How can I save the current text of a note annotation while it’s being edited?

A: When the text of a note annotation is modified, the modification is not applied to the note until the note is closed. This complies with the expected behavior of note annotations, which work a bit as a draft notepad where changes are not committed until we close it.

However, there may be scenarios where the desired outcome is that the text is automatically saved to the note on each keystroke; for example, when you cannot ensure that the note annotation component will receive the signal to update the annotation in the global state.

You can achieve this by listening to the native keydown event:

PSPDFKit.load(defaultConfiguration).then(instance => {
    function(event) {
      if ( === instance.contentDocument.activeElement &&".PSPDFKit-Note-Annotation-Content")
      ) {
        const element =;
        // Let the event pass by so the character is added to the note
        setTimeout(() =>
            instance.getSelectedAnnotation().set("text", element.innerText)
    { capture: true }

  instance.addEventListener("annotations.update", annotations => {

This has been tested with PSPDFKit for Web 2020.5.0