Catching unsaved content in entry editors

Hi, is there a way to catch when the user is navigating away from editing a singleton/collection entry with unsaved changes?
I would like to show my users a little confirmation box before accidentally discarding changes.

That is not possible OOB, but maybe with some JS where you need to capture the click events, in such case if you are concerned with losing changes you can check the AutoSave add-on as the purpose is exactly to avoid that -

Oh! That’s perfect. Thank you. How did I not find this addon.