Phonegap event-menu key html5 menu event

Source: Internet
Author: User

The Phonegap intercepts the menu button event menubutton, which is used to process the menu interception event in html5.

This event is triggered when the user presses the menu

document.addEventListener("menubutton", yourCallbackFunction, false);


Supported platforms:

Amazon Fire OSAndroidBlackBerry 10

Simple Example:

document.addEventListener("menubutton", onMenuKeyDown, false);function onMenuKeyDown() {    // Handle the back button}


Complete example:

      Menu Button Example<Script type = "text/javascript" charset = "UTF-8" src = "cordova. js "> </script> <script type =" text/javascript "charset =" UTF-8 "> // Wait for device API libraries to load // function onLoad () {document. addEventListener ("deviceready", onDeviceReady, false);} // device APIs are available // function onDeviceReady () {// Register the event listener document. addEventListener ("menubutton", onMenuKeyDown, false);} // Handle the menu button // function onMenuKeyDown () {// execution of the menu button} </script>    


Deviceready only needs to be loaded once. It indicates that it is called when the phonegap API is loaded.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.