Reputation: 309
it is possible to capture the "back button" Keypress in Android with jquery?. I ve got a Close Button and I want to use the back button from my Android to close the modal window.
Can this be done without Java, only with JS or jQuery?
Thanks
Upvotes: 3
Views: 4165
Reputation: 15982
You can detect it using the keycode
$(document).on('keydown', function(event) {
if (event.keyCode == 27) {
// Prevent default (disable the back button behavior)
event.preventDefault();
// Your code
}
});
Upvotes: 1