How to detect back click on navBar?

Hi, I want to implement click back on navBar to auto save data. but how do I detect that back button navbar is clicked. I have no Idea. thank you.

image