This is the code I use to assign a key to a operator:
sub_box = col.box()
header_row(sub_box.row(align=True), 'show_posing', label='Posing')
if preference.keymap.show_posing:
sub_box = sub_box.box()
sub_box.separator()
keymap = key_config.keymaps['3D View']
km_item = get_keymap_item(keymap, 'redthread.rotate_bone_hier', 'none', 'none')
if km_item:
sub_box.context_pointer_set("keymap", keymap)
rna_keymap_ui.draw_kmi([], key_config, keymap, km_item, sub_box, 0)
else:
sub_box.label(text="Hotkey not found")
sub_box.separator()
keymap_item = keymap.keymap_items.new("redthread.rotate_bone_hier", type='NONE', value='PRESS')
keys.append((keymap, keymap_item))
If I want this key to only be affecting pose mode, and not conflict with keys in other modes, what would I need to do?