How to create an empty hotkey?

To add a hotkey to a new tool you use this snippet here:

        # handle the keymap
    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
    kmi = km.keymap_items.new(myplugin.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True)

    addon_keymaps.append ((km, kmi))

The hotkey itself gets defined at the line starting with kmi. So far so good.

But i want to create an empty hotkey so that the users can define their own hotkey in the right click menu when they want. When i leave the kmi line away then the user does not have this option. And when i leave the hotkeys away then Blender moans.

How do i define an empty hotkey? One that allows the user to add their own one by right click? Like the one in my example image.

And while at it, is there a good tutorial when it comes to the hotkeys? The api doesn’t really make me happy here …

Attachments


Don’t add a hotkey at all in code, just add the operator to a panel. User can right-click the button and Add Shortcut.

Don’t add a hotkey at all in code, just add the operator to a panel.

Thanks CoDEmanX,

That’s what i try to find out here. How? Which code bit is it? And how to apply? As told, when i leave the kmi part away then there is no right click item to add your own shortcut. And when i modify the kmi line to leave the hotkeys away then Blender moans. And i cannot find any info how to do it. My google-fu is not good enough :slight_smile: