Modeler shortcuts work even when various dialogs are opened above it

If I open a modal dialog or any other DIV that has focus all shortcuts still take effect in the modeler below.
How to reproduce:

  • Open online modeler https://demo.bpmn.io/new
  • Select an element in the diagram
  • Click on the bpmn.io logo in the lower right corner
  • Now we have a modal dialog that in theory should not allow us to manipulate elements below it
  • Click [Del] key on your keyboard
  • The selected element in the diagram below the dialog gets deleted

Is this the expected behavior? And is there any workaround for this?
I think that there should be a check that should determine where the event was triggered from. If it was not triggered from inside the modeler itself then these events should be ignored.

This is a bug and related to this issue. Right now there is no way to figure out whether the editor actually has browser focus.

Because of that circumventing this issue is not easily possible.

Is there a way to manually turn keyboard events off and on again after modeler in already initialized?