Detect smartphone back button

3

Is there any way to detect when the physical back button of the smartphone is clicked?

I need this to close a modal .

I thought there might be a matching number like on the keyboard and use event.which to detect but could not find.

    
asked by anonymous 09.10.2018 / 21:40

1 answer

0

What you can do is use the History API ( link ). When you open the modal would be like entering another page, hence the back button of the android and also the browser will be able to return to the previous state when triggered. You do not need to know the code of the button nor does it depend on its existence, since the browser also has one.

    
16.10.2018 / 13:11