# Is there a way to create a copy of the default keymap configuration?

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?

Holy smokes, this was miserable to figure out but this appears to work:

        import bpy

wm = bpy.context.window_manager
CopiedMap = wm.keyconfigs.new("CopiedMap")

#Get list of default keymap items
keymaps = wm.keyconfigs.default.keymaps.items()
for i in keymaps:

#Put default values in to new keymaps
CopiedMap.keymaps.new(i[1].name, space_type= i[1].space_type,
region_type=i[1].region_type)

#Get list of default keymap_items contained
#within the keymap
keymap_items = i[1].keymap_items.items()
for j in keymap_items:

#Put values in to new keymap_items
CopiedMap.keymaps[i[1].name].keymap_items.new(j[1].idname, j[1].type, j[1].value, any=j[1].any,
shift=j[1].shift, ctrl=j[1].ctrl, alt=j[1].alt,
oskey=j[1].oskey, key_modifier=j[1].key_modifier)


I'm not a very good scripter so this is probably not a very good answer, but maybe it'll get you by until somebody better at this comes along. :)