How to properly hook custom keyboard events

hi all.
I think I have a question I was not able to find already answered (something near is this thing Separate keyboard shortcuts for canvas and selected elements - #2 by nikku)

so what I would like to do : we have custom build of bpmn-js + some tweaks like custom render, custom contextpad and custom palette.

I would like to have custom keyboard events that I can hook on a page I will host my build of bpmn-js and I could listen to them via eventBus since IMO that is the correct thing to do.

I have changed a bit the sample from above and for me this code works :

import KeyboardBindings from 'bpmn-js/lib/features/keyboard/BpmnKeyboardBindings';

class CustomKeyboardBindings extends KeyboardBindings {
  constructor(injector) {
    super(injector);

    injector.invoke(KeyboardBindings, this);
  }

  registerBindings(keyboard, editorActions) {
    // register another listener with a higher priority so it's called first

    keyboard.addListener(10000, context => {
      const event = context.keyEvent;

      // check whether the key pressed is 'o' + CTRL
      if (event.ctrlKey && keyboard.isKey(['o'], event)) {
        event.preventDefault();
        keyboard._eventBus.fire('custom.openDiagramEvent', event);
      }

      // check whether the key pressed is 's' + CTRL
      if (event.ctrlKey && keyboard.isKey(['s'], event)) {
        event.preventDefault();
        keyboard._eventBus.fire('custom.saveDiagramEvent', event);
      }
    });
  }
}

export default {
  __init__: ['customKeyboard'],
  customKeyboard: ['type', CustomKeyboardBindings],
}

in the JS on the page where I listen to events I can hook them like this :

  //listens for CTRL + o triggered via eventBus
  eventBus.on('custom.openDiagramEvent', function (event: Event) {
    diagramsClicked();
  });

my concern in that in the sample there was this signature

public registerBindings(keyboard, editorActions, eventBus) {

which never worked for me (the eventBus prop was never passed from caller) and I had to use the

keyboard._eventBus.fire('custom.openDiagramEvent', event);

which is IMO using private prop of the keyboard obj.

any idea on how the hooking to custom event should look like? thx

I was looking here bpmn-js/lib/features/keyboard/BpmnKeyboardBindings.js at develop · bpmn-io/bpmn-js · GitHub and it seems this code is triggering EditorActions (can be seen here bpmn-js/lib/features/editor-actions/BpmnEditorActions.js at develop · bpmn-io/bpmn-js · GitHub) but this to me looks like built in stuff from the editor and not something I should call since I am hooked from the outside.

in case anyone would try this code, the call

injector.invoke(KeyboardBindings, this);

happens also in super(injector); so running old code will trigger the handlers 2x