Prevent the deletion of annotations on pressing the delete key.

Here is how you can override this in the latest versions.

const { Tools } = instance.Core;

const DELETE_KEY = 46;
const BACKSPACE = 8;

const originalKeyDown = Tools.AnnotationSelectTool.prototype.keyDown;
Tools.AnnotationSelectTool.prototype.keyDown = function(e) {
  if (e.which === DELETE_KEY || e.which === BACKSPACE) {
    return;
  }

  originalKeyDown.apply(this, arguments);
};
1 Like