简体   繁体   English

如何将箭头键传递给Javascript,而不是移动WebView本身?

[英]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. 我有一个带有键盘控制的javascript的WebView,但是遇到一个问题:Webview不会将箭头键传递给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. 当我启动此Activity并按箭头键时,WebView会移动并且加载的页面中的JavaScript不会触发。 Other keys like Enter or alphabets work well. 其他键(例如Enter或字母)效果很好。

Is there a way to bypass arrow keys into web pages? 有没有一种方法可以绕过箭头键进入网页? Thanks. 谢谢。

You have to override onKeyDown method for view. 您必须重写onKeyDown方法以进行查看。 You can find how to do that here. 您可以在此处找到操作方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在jQuery / javascript中获取文本本身而不是文本元素顶部的位置 - How to get position of top of text itself, rather than text element, in jQuery/javascript 在JavaScript中引用JSONObject时,如何使用变量(而不是名称本身)引用它? - When referring to a JSONObject in javascript, how do I refer to it using a variable (rather than the name itself)? Javascript:通过引用而不是通过值传递函数 - Javascript: pass function by reference, rather than by value 如何使用默认浏览器而不是使用Javascript的Webview打开新链接? - How do you open a new link in the default browser rather than the webview with Javascript? 如何停止打印“ [object Object]”而不是对象本身? - How to stop “[object Object]” from printing rather than the object itself? 如何动态传递实际的javascript数组而不是在eventListener中手动传递? (FullCalendar) - How can I pass an actual javascript array dynamically rather than manually in an eventListener? (FullCalendar) 如何使用JavaScript加载页面而不是重定向? - How to load pages with JavaScript rather than redirect? Axios post 方法正在发送一个对象,其中我的数据作为键和空值,而不是整个数据对象本身 - Axios post method is sending a object with my data as the key and empty value rather than the whole data object itself Javascript和Dvorak:有没有办法让按键而不是角色? - Javascript and Dvorak: Is there a way to get the key pressed rather than the character? 显示社交图标,而不是带有光笔画的箭头 - Display social icons rather than an arrow with photoswipe
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM