How do I give operators of my addon the "Assign Shortcut" button?

Hi there! So Ive noticed that the popup menu which appears when right clicking any of the operators registered to the UI in my addon is missing the “Assign shortcut” button. I can still go into the keymaps preferences and add an entry there manually. I can also just add a hotkey using bpy using something like:

keyConfig.keymaps[“Window”].keymap_items.new(“fast_pbr.fast_upbge_pie”, type=“NONE”, value=“PRESS”)

Where setting the type (which determines which key is assigned to the keymap entry we are adding) to NONE one would imagine the “Assign shortcut” thing to appear in the RMB menu, of which it does not (setting it to “NONE” results in no change to the RMB menu, setting it to anything but “NONE” results in “Change shortcut” to appear in the menu, but then we are assigning a shortcut, which in my case is undesired as I just want to make it easy for the users to assign a shortcut without actually holding any keys hostage by default).

Does anyone know how to get this
image
button to appear?

Thanks for reading :gift_heart:

I think you need to make Keymap items for them, even if you leave them blank.
There’s an example of a keymap entry here, but this addon defines the keys. I think you can leave it blank.
My addon does this, too, and it looks like I can right-click its operators and change the shortcut.

Hey thanks for the answer! For me if I dont feed the type & value parameters it tells me that they are non-optional. How would I leave them “blank” exactly?

If I set them to “NONE” the “Assign shortcut” thing never appears.

I want to empathise here btw that Im somewhat specific that I want my operators to lack hotkey by default, as I have like 20 or so operators that I really dont want to clug peoples keymaps with but instead let them conveniently assign ones of there choosing to the operators they use the most :slight_smile:

it cause by the bl_idname of the operator
if you set it as ‘my_addon.my_operator’, it cant only assign short cut by coding
if you set it like ‘mesh.my_operator’ or ‘wm.my_operator’(whose types before"." is build in with blender), it can be assign short cut by user.