Using Back Key (hardware key) to close web browser

Using Back Key (hardware key) to close web browser

BY 19 Aug 2013 Web Application Development

I have a web app that views external website. This is not a problem. However, when the browser is opened I am unable to use the “Back” hardware key in the simulator to close the browser to return to the app.  I have tried to assign a listner to the browser app but with no success. I am able to use the below listed code to successfully use the “Back” button throughout my app but it doesn’t work for the browser.

[IMPORTANT] Is there any way to assign an Event Listner to the browser app so that when the “Back” key is pressed it will close (exit) the browser?

 

document.addEventListener( ‘tizenhwkey’, function(e) {
 
if (e.keyName === ‘back’) {
if ($.mobile.activePage.attr(‘id’) === ‘indexJump’) {
tizen.application.getCurrentApplication().exit();
} else {
history.back();
}
}
 
});
 
Thanks,
Ethan-Anthony
Written by