I am trying to listen for the user is pressing one of the buttons: Back, Start or Search , on a Windows Phone, and simply output an alert if the condition is true:
e.g. alert("user pressed start");
Is this possible?
I'm trying to find out if the user is about to close the browser and execute a function before he does. On desktop browsers this is easily done with onbeforeunload
, but this does not seem to work on mobile browsers.
3 Answers
Answers 1
Those are hardware buttons, handled by the OS, not your website, so no, You can't do that.
Answers 2
Look at this answer: Bind to mobile device hardware buttons
Basically if you make an hybrid app with a framework such as Cordova Phonegap you can bind an event listeners to physical buttons.
Answers 3
You can receive key events for the back button and the camera button.
as you see here : https://msdn.microsoft.com/library/windows/apps/jj207557 .
Some help: (How can i receive the hardware key button event On Windows phone 8?)
By the way, i think isn't worth the trouble. These keys are intended for exclusive use of the OS and you won't have any real benefit for your app by hacking that behaviour.
0 comments:
Post a Comment