That’s why I don’t have instance object, so I cannot follow this topic to prevent Delete key pressing behaviour. I see that, when I press the Delete key, the delete action (for annotationManager) is triggered and the annotation vanishes from the PDF file. I don’t want to that.
I tried to define addEventListener for documentViewer and stop Delete key by preventDefault or stopPropagation, but it doesn’t work. I even tried to get an advice from this topic, but the only effect, that I can achieve, is an infinite loop.
OK, I could probably prevent this with the document (not documentViewer), but I still want to use Delete key in a form, when an annotation is selected.
In my case, is it even possible to programatically stop deleting annotations after pressing Delete key?
You mentioned that you tried adding a confirmation popup before deleting and that causes an infinite loop? Could you explain this in more detail? What errors are you receiving and could you provide the code?
One possible solution could be to redraw the annotation whenever a user deletes it. Would something like this work for you?
Yes! This is exactly what i meant earlier . This solution is even beter, because I don’t have to remember to “unblock” the deletion if I want to programatically remove annotations. Also, I just realized that Backspace button behaves the same way (although it should be obvious for me). Thank you for all your help.