When my mouse in properties panel, How can I create a shortcut such that when I press 'FIVE' then toggle to modifier panel.
Blender Ver: 2.91
bpy.ops.wm.context_set_enum(...)
Setting a value from a context path for a shortcut use one of the bpy.ops.wm.context_set... operators
>>> bpy.ops.wm.context_set_
boolean(
enum(
float(
id(
int(
string(
value(
This one is an enum property (string would work too)
>>> bpy.ops.wm.context_set_enum(
context_set_enum()
bpy.ops.wm.context_set_enum(data_path="", value="")
Set a context value
For the equivalent to
bpy.context.space_data.context = 'MODIFIERS'
using an operator will be,
bpy.ops.wm.context_set_enum(
datapath="space_data.context",
value='MODIFIERS',
)
cannot test this in python console because it is not in the correct properties space context, instead add it manually to test, Edit > Preferences > Keymaps > Properties Edit
...Ok numpad 5 now switches to modifiers tab.
To set up shortcut using python see