Custom Fields – JS hooks and updating

I’m finding the docs on custom fields is very limited and following the code in the existing panel fields quite complex to break down considering there’s very little documentation in them.

I simply need to have a custom field which a user enters a vimeo video ID and, once saved, calls the official vimeo API to retrieve all the data and save it to the current page.

I have the API working and saving the data but only when editing the panel page and the vimeo ID already exists. Ideally I’d love this to happen inline, as soon as the ID is captured, but I’m confused how the JS is executed for the custom field.

Following the code in the already existing structure field, does anyone know how the communication happens between the js and scripts?