Delete shortcut is working when the context menu is opened

I have to restrict certain keybindings such as deleting while the context menu is opened. how to do that, can we achieve that through context or when clause? if possible how?

@vince-fugnitto @msujew