blender key config without index

I need some help to solve that,

bpy.ops.object.create_view()

----------------------------------------------

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

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

What can I use instead index?

Hmm
The key name?

#get the keyconf
conf = bpy.context.window_mananger.keyconfigs.active 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”
try:
map = conf.keymaps[mapstr]
except:
map = conf.keymaps.new(name=mapstr)

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.