How to use global shortcuts inside native module?

Godot Version

4.2

Question

This topic about shortcuts inside native C++ modules.

If I want to define a shortcut inside my module I use this code:

...
my_btn->connect("pressed", callable_mp(this, &MyModule::do_smth));
my_btn->set_shortcut(ED_SHORTCUT("my/path", "My Name", KeyModifierMask::CMD_OR_CTRL | Key::M));
add_child(my_btn);

It works, but I don’t want to create a fake UI element for this. And I can’t find a way how to implement some shortcut globaly. Inside the editor code I see one place where I see something similar to my desire godot/editor/plugins/node_3d_editor_plugin.cpp at a9bb8509f2faac81bdb995c6c89a5347372f3498 · godotengine/godot · GitHub

But it doesn’t work If I copy corresponded code to my module.

So, how to define global shortcuts inside native module correctly?