I'm trying to programmatically create a Key Configuration that is a copy of the Default configuration except all "S" and "O" mappings are swapped.
eg.
Ctrl+O -> Ctrl+S
Alt+S -> Alt+O
I was able to swap the Key Mappings of the Default Key Configuration with the following code:
wm = bpy.context.window_manager
default = wm.keyconfigs['Blender'] # Default Key Configuration
for keymap in default.keymaps:
for keymap_item in keymap.keymap_items:
if keymap_item.type == 'O':
keymap_item.type = 'S'
elif keymap_item.type == 'S':
keymap_item.type = 'O'
However, I cannot find a way to create a copy of the Default configuration, since making a new configuration (wm.keyconfigs.new()
) doesn't actually copy the Defaults instead it just creates an empty Key Configuration where you cannot iterate over the keymaps
(since they don't exist).
So, is there a way to create a copy of the default configuration?