There's already an Add-On for this, although I don't know what it is. But it would be possible.
Package the specific event's function.