The only solution I have found is to have a global Input.input.addEventListener() call (rather than adding an event listener per context menu) and through it call a global callback that is updated by the context menus.
// Weak map mapping to Input listeners of submenus reliably.
// The keys are the submenu lists themselves, not the submenu representing items.
const submenuInputPressedListeners = new WeakMap<HTMLDivElement, Function>();
// Globalized input action listener
Input.input.addEventListener("inputPressed", function(): void
{
currentInputPressedListener?.();
});
(Updated with either currentInputPressedListener = input_onInputPressed; or currentInputPressedListener = null;, instead of Input.input.addEventListener or removeEventListener)
Now am I doing this to test navigation input on submenus from outer context menus:
// Check input on submenu
submenuInputPressedListeners.get(submenus[submenus.length - 1])();