# Registration
addon_keymaps = []
def register():
bpy.utils.register_class(precision_draw_tools_bm)
bpy.utils.register_class(precision_draw_tools_cm)
#bpy.types.VIEW3D_MT_edit_mesh_vertices.append(draw_menu)
# handle the keymap
wm = bpy.context.window_manager
# Note that in background mode (no GUI available), keyconfigs are not available either,
# so we have to check this to avoid nasty errors in background case.
kc = wm.keyconfigs.addon
if kc:
km = wm.keyconfigs.addon.keymaps.new(name='Window', space_type='EMPTY')
kmi = km.keymap_items.new(precision_draw_tools_cm.bl_idname, type = 'P', value = 'PRESS', ctrl=False, shift=True)
addon_keymaps.append((km, kmi))
km = wm.keyconfigs.addon.keymaps.new(name='Window', space_type='EMPTY')
kmi = km.keymap_items.new(precision_draw_tools_bm.bl_idname, type = 'P', value = 'PRESS', ctrl=True, shift=True)
addon_keymaps.append((km, kmi))
And the unregister like this:
def unregister():
# handle the keymap
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
bpy.utils.unregister_class(precision_draw_tools_cm)
bpy.utils.unregister_class(precision_draw_tools_bm)