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.
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.
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.