Attach invoke or execute to boolproperty on change

In register I have an initialize function, which adds a boolproperty named key.median.


def initialize():
    bpy.types.Scene.key_median = BoolProperty(
        name="Median Point?",
        description="pivot choice",
        default=True)

and then it’s added to a panel with


layout.prop(context.scene, "key_median")

I want to attach a listener, or invoke, or execute, or onStateChange() – some way to run code when the checkbox is changed. Where should I look for that?

https://www.blender.org/api/blender_python_api_2_76_2/bpy.props.html?highlight=boolproperty#bpy.props.BoolProperty
Note the update, get and set functions.

def test_update():
print(“updated”)

test = bpy.types.BoolProperty(name=“bla”, update=test_update)

Thanks you that works. In my case, the update method must include context and self as parameters.