Prevent Keyboard copy/paste of nodes

Hi,

I want to disable the copy and paste of my GoJS node using the keyboard shortcuts Ctrl+C and Ctrl+V. But i need this function to happen on click of a button in my context menu.

this.diagram.allowCopy = true; allows duplication with both keyboard and button click .
this.diagram.allowCopy = false; prevents both.

this is my function to duplicate the node via context menu click:

('ContextMenuButton', { 'ButtonBorder.fill': 'white', '_buttonFillOver': 'lightgray' }, (go.TextBlock, ‘Duplicate’,
{ margin: 12 }
),
{ click: (e, pt, compInstance) => this.duplicateComponent(compInstance, pt, e) })

duplicateComponent(compInstance, pt, e) {
this.diagram.commandHandler.copySelection();
const point = new go.Point(e[‘Ir’][‘offsetX’] + 20, e[‘Ir’][‘offsetY’] + 20);
this.diagram.commandHandler.pasteSelection(point);
this.propertiesFlagEvent.emit(’’);
this.startAutoSave();
}

How can i prevent just the keyboard shortcuts?

Override CommandHandler.doKeyDown GoJS Commands -- Northwoods Software not to call the super method upon control-C, control-Insert, control-V, and shift-Insert.

By the way, if you find that our forum replies provided answers, it would be helpful if you marked them as “solving the problem”. It’s the checkbox button shown after clicking the horizontal three dots button. I noticed that you never responded to all of the other answers I’ve given you recently. If you could review them all, or at least tell me that they were all useful in solving your problems, that would be helpful.

Thanks for marking topics as “solved”.