Is there any way to toggle blender's Boolean command state while pushing keyboard shortcut? I always enable weight paint tool's Restrict mode but sometimes I need to disable it. I would like to disable weight paint tool's Restrict mode while I keep pushing keyboard shortcut and when I release the key Restrict mode needs to be enabled again. I would like to do something like sculpt tool's temporal smooth brush which is activated when I keep pushing shift key.(default setting of sculpt tool shift key works as sculpt.brush_stroke with Stroke Mode:Smooth)
I assigned 2 custom python script to A key.
this one works when A key is pushed
bpy.context.scene.tool_settings.weight_paint.use_group_restrict = False
And this one works when A key is released
bpy.context.scene.tool_settings.weight_paint.use_group_restrict = True
but it doesn't work always. When I push A key it surely disables Restrict mode but sometimes Blender fails to get key release state and 2nd python script isn't executed. I guess it's because I do weight paint while I keep pushing A key, and this brush stroke thing disrupts Key release event?
If you know much smarter way please tell me.