Shortcut Visualizer : get keymap shortcuts by key?

Someone knows if there is an addon for visualize the shortcuts in blender?

I was thinking that could be useful have a panel to call to “See” the key in a context.
And see if E is unused for example
or if Q have only 1 shortcut
and if a key like R have more than 1 , be able to read them .
Like this
There is any way to have custom tooltips ? like the one that popup when we hover on a buttton?

Searching how get the shortcut from blender i found this post
but i am unable to understand how , search for all keymaps in blender and Rearrange them by Key.

something like this should give you enough information to go on:

import bpy

wm = bpy.context.window_manager

kc = wm.keyconfigs.user

def get_full_keybind_string(kmi, idname=True, props=False, include_idname=True):
    output = f"{kmi.type} [{kmi.value}]"
    if kmi.any:
        output = "ANY+" + output
    else:
        if kmi.shift:
            output = "SHIFT+" + output
        if kmi.alt:
            output = "ALT+" + output
        if kmi.ctrl:
            output = "CTRL+" + output

    return output
    

keystroke_lookup = {}
for km in kc.keymaps:    
    for kmi in km.keymap_items:
        keystroke = get_full_keybind_string(kmi)
        if keystroke not in keystroke_lookup:
            keystroke_lookup[keystroke] = []
        keystroke_lookup[keystroke].append((km.name, kmi.idname))

for keystroke in keystroke_lookup:
    print(f"The following operators are bound to {keystroke}:")
    print("------------------------------------------")
    for keymap, idname in keystroke_lookup[keystroke]:
        print(f"  {keymap} - {idname}")
    print("")


1 Like

Thank you very much man !
I am pretty sure that its all what i was asking for !
I will try to wrap mi head around !
thanks for your time !

Hi again, there are a lot of shortcuts that have the same “name” but with different attributes.
Some shortcuts are linked to "context attrivute " some other to “identifier” , and i have my own operator with a prop named “WORD”.
And for example , from the “Tool set by id” , i would like to know which tool he will set XD

I took a look at the blender api but as always i dont understand where search :slight_smile:
is this the wrong page?
https://docs.blender.org/api/current/bpy.types.KeyMap.html?highlight=keymaps%20items

ah yeah, i almost added that to my example but left it out to keep things more simple- you can check properties on a keymap item, once you have the props you can compare them to see if they are the same or not:

propstring = ""
if hasattr(kmi, "properties") and kmi.properties is not None:
    for key in kmi.properties.keys():
        if not isinstance(kmi.properties[key], idprop.types.IDPropertyGroup):
            propstring += f"{key}: {kmi.properties[key]}, "
        else:
            # this keymap item is actually a macro
            propstring += f"MACRO: {key}, "

print(propstring)
1 Like