I set a blender shortcut for a custom operator in my addon using the code described here: Create keyboard shortcut for an operator using python?
When I install the addon the shortcut is registered and works fine. But when I close and reopen blender the shortcut has disappeared from the keymap in edit > preferences. However, the addon is still activated. When I deactivate and reactivate the addon the shortcut reappears and it works. How do I make the shortcut stay?
I tried using the code in the link above instead of my own code as a test and the same problem occurs.
bpy.ops.wm.save_userpref()If that doesn't work, then perhaps the code you're using is broken, although it looks OK to me at a first glance. – Marty Fouts Oct 04 '21 at 15:59