Turn Off Keyboard Shortcuts

Hi, I am writing some code where I can start and stop things via keyboard input, which much easier and faster than writing UI code. However the predefined UI keyboard shortcuts - that I don’t need - get in the way. So if I try and use S for example, then it causes the scale tool to activate.
Is there a way to turn that processing off? Or “get in front” of it and cause that “S” to no longer get through?
The code I am using looks like this - copied it from something -forgot what.

            if keyboard.is_pressed("S"):
                k = keyboard.read_key()
                rocuWrap1.ToggleCirclingTarget()
                if rocuWrap2 is not None:
                    rocuWrap2.ToggleCirclingTarget()
                print(f"You pressed ‘S’. circle_target is now:{rocuWrap1.circle_target}")

I was hoping that “read_key” command might keep the “S” from getting through, but no such luck.

One manual method would be to just go to the “HotKey Editor” inside Isaac. Then you can find the specific keyboard shortcut you do not want and delete or change it.

1 Like

Well, the problem with that is I don’t want them turned off when I use Isaac Sim by itself - just when I am running particular experiments that use Isaac SIm.

Also I have to turn them all off which is a pain - and if I gave the code to someone else to try it out (which I do) - they would have to do the same thing.

So I thought of that, but it is not really what I want.

If I could turn them on and off with an API that might help.

like this?

hotkey_registry = omni.kit.hotkeys.core.get_hotkey_registry()
discovered_hotkeys = hotkey_registry.get_all_hotkeys()

# To print current hotkeys
for hotkey in discovered_hotkeys:
    print(hotkey)
    print(hotkey.key_combination)

# To delete hotkey
hotkey_registry.deregister_hotkey("omni.kit.manipulator.tool.snap", "S")
1 Like

Why not just use HotKeys that you know are not already in use with the HotKey Editor ? That solves all the problems in one go. This is why you can use unique combinations, like “Shift + Ctrl + 1” etc.

Because they took the good ones. :)

This is the code I ended up using to delete them all.

    def DeRegisterAllHotKeys(self):
        hotkey_registry = omni.kit.hotkeys.core.get_hotkey_registry()
        discovered_hotkeys = hotkey_registry.get_all_hotkeys()
        print(f"There are now {len(discovered_hotkeys)} hotkeys.")
        delete_list = discovered_hotkeys.copy()
        for hotkey in delete_list:
            try:
                hotkey_registry.deregister_hotkey(hotkey)
            except Exception as e:
                print(f"Failed to deregister hotkey:{hotkey} {e}")
        discovered_hotkeys = hotkey_registry.get_all_hotkeys()
        print(f"After deletion there are now {len(discovered_hotkeys)} hotkeys.")

Notes;

  • the “copy” is necessary since you have a reference to the original list which you can’t use in an iterator while modifying it.
  • 69 hotkeys get deleted everytime I run this, so they are obviously not being “permanently deleted” - which is what I want.
  • Thanks to Richard3D and hijimasa for helping out.
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.