Why am I getting multiple hotkey entries in my key configuration file?

I have many copies of the same hotkeys in my key configuration file. Like this:


I understand that some scripts assign hotkeys like this:

create the mode switch menu hotkey

km = kc.keymaps.new(name=‘3D View’, space_type=‘VIEW_3D’)
kmi = km.keymap_items.new(‘wm.call_menu’, ‘Q’, ‘PRESS’, alt=True)
kmi.properties.name = ‘mode.switch_menu’
kmi.active = True
addon_keymaps.append((km, kmi))

Why do I have ten or eleven copies of the same key in my key file? Is it the ‘append’ method doing it? So whenever I toggle an addon on and off I get another copy of the hotkey in my key file?

It sounds like the addon just blindly adds its hotkeys when it gets enabled, regardless of whether they exist or not, and/or it doesn’t bother to remove them when it gets disabled.

each time you import a config it adds its keys…

That makes sense. It makes a mess of the key config file. It there a way to fix it globally, or does each script have to check if the entry already exists in the key config file?

I get this all the time.
I’ve been harping on the state of the Hotkey Editor (/engine). Both function and design. It’s a big roadblock in successfully remapping/maintaining keys, especially for those new to Blender.
This should be high on the task of fixing things.

Unfortunately this is not just a matter of fixing, this definitely needs a thorough thought out redesign that goes a little deeper than just concerning direct keys to commands. Specifically for instance, the navigation across all Editors/Windows should be set on one global level. (there can be an advanced option for those adventurous who want to navigate each window in a different fasion).

I think I figured out my problem with the key file. I had been exporting my key file each time I make changes to my hot keys. But all I really need to do is Save User Settings, which I had been doing all along. But I had also been exporting the key file on top of the existing key file that I had already exported.

But Save User Settings saves everything including keys into the userpref.blend file, so the key changes are saved.

I should use Export Key File for backups only. And I should not write on top of an existing key file because scripts just append their key settings to the existing file. I was ending up with key files nearly 3000 lines long.