简体   繁体   中英

How to pass arrow key to Javascript rather than moving WebView itself?

I have a WebView with keyboard-controlled javascript in it, but then meet a problem that: Webview won't pass the arrow key to Javascript. Codes are like:

public void onCreate(Bundle savedInstanceState) {
    mWebView = new MyWebView(this);
    setContentView(mWebView);
}

When I launch this Activity and press arrow key, the WebView moves and JavaScript in loaded pages does not trigger. Other keys like Enter or alphabets work well.

Is there a way to bypass arrow keys into web pages? Thanks.

You have to override onKeyDown method for view. You can find how to do that here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM