Run script when pressing [F4]

Hello,

I use the F4 button for the revit function “Finish editing circuits”.
I want to start a script at the same time or after.
I think it might be possible with event register or something like that but I cant seem to figure it out