blender key config without index

I need some help to solve that,



XXX, this isnt future proof, DON’T USE INDEX’s - campbell

km =[‘WinMan’].keyconfigs[‘Blender’].keymaps[‘3D View’]
km.keymap_items[3-1].idname = ‘view3d.rotate_view3d’

What can I use instead index?

The key name?

#get the keyconf
conf = or
conf = bpy.context.window_mananger.keyconfigs[‘Blender User’] (Using this will save your keys when “Save default settings” is pressed)

#get the keymap

mapstr = “3D View”
map = conf.keymaps[mapstr]
map =

key = map.keymap_items[‘view3d.rotate’] (if the key doesnt exists you will have to create a new one using try: except:
key.map_type = “MOUSE”
key.type = “RIGHTMOUSE”

thanks for your anser, i wil try something like this.