Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4071000
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:42:03+00:00 2026-05-20T16:42:03+00:00

HI, I have an @override that I use in native Android that scrolls the

  • 0

HI, I have an @override that I use in native Android that scrolls the webView(scrollView)using the device volume keys. This is a real nice feature for the user when he/she is using one hand. I would like to use it with Phonegap. Obviously I cant use the: WebView scrollView = (WebView) findViewById(R.id.ch01); So How can I use/implement feature with Phonegap or pass the function w/to jQuery??

Some code will be helpful – I am on a tight learning curve with jQ & Phonegap. Thnx!

This is the override I use:

    @Override
// --------------- Set the Device Volume Keys to Scroll the WebView -->
public boolean dispatchKeyEvent(KeyEvent event) {
    int action = event.getAction();
    int keyCode = event.getKeyCode();
    WebView scrollView = (WebView) findViewById(R.id.ch01);
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (action == KeyEvent.ACTION_DOWN) {
            scrollView.pageUp(false);
        }
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (action == KeyEvent.ACTION_DOWN) {
            scrollView.pageDown(false);
        }
        return true;
    default:
        return super.dispatchKeyEvent(event);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:42:04+00:00Added an answer on May 20, 2026 at 4:42 pm

    The easiest, quickest way to do this would be to extend the onKeyDown method override in DroidGap.java. Add a few cases to the conditional, catching the volume keys, and using the same approach you see that exists in this method, you can directly invoke JavaScript by calling something like:

    this.appView.loadUrl("javascript:alert('hello world!');");
    

    Of course, you would probably change the alert call to something else specific to your application, or perhaps even directly calling window.scrollBy to do the scrolling.

    A better, more modular approach would be to encapsulate this functionality into a PhoneGap plug-in. You could then contribute it back to the community as I’m sure others would appreciate and make use of this as well! 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of classes (for this example anyway) that use code first
I have some applications (some native, some .NET) which use manifest files so that
I have code that overrides the TextBox ProcessCmdKey method: protected override bool ProcessCmdKey(ref Message
I have a class that extends View. I override the onDraw method and allow
I have a class that derives from ImageView . In its onDraw method override
How can I override the IsValid property? I have a model that's validating as
I have a custom control that inherits from .NET's CompositeControl class. This control overrides
i have override validate method and added errors using addFieldError(test, test print); and in
I have this code: @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { GLES20.glClearColor(0, 0,
I have some resources I must access with SSL that use self-signed certificates. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.