如何从网页处理 Android 轨迹球事件?
Webkit 中是否有与轨迹球事件(移动和按下)相关的 DOM 事件?
或者还有其他方法可以从网页处理这些事件吗?
Is there any DOM event in Webkit associated to trackball events (movement and pressing)?
Or is there any other way to handle those events from a webpage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有测试过,但我知道在 Android API 中,轨迹球最终会以 DPAD_UP、DOWN、LEFT、RIGHT 的形式发送。这些可能会映射到您的 JavaScript 箭头键。新闻事件可能是左键单击或 RETURN。
编辑
我创建了一个超级简单的页面,它将记录到 android 日志文件,无论页面上看到什么输入事件。 http://imaiparrott.org/bugs/input.html。在 Android 浏览器中转到那里,尝试输入事件并在 adb logcat 中查看它们。据我所知,我的轨迹球根本没有注册任何事件。你可能不走运......
另一方面,根据你的网站到底是什么,我可以想到一种奇怪的方法来做到这一点......轨迹球聚焦可聚焦的 DOM 对象。如果您的页面不需要标准 DOM 对象可聚焦(可能像游戏),那么您可以创建几种“隐藏”DOM 对象并监听它们的 DOMFocus 事件。通过巧妙的事件组合,您可以找出触发了哪个轨迹球事件。
I haven't tested it, but I do know that inside the Android API, the trackball eventually gets sent as DPAD_UP,DOWN,LEFT,RIGHT. These might map to your javascript arrow keys. A press event might be left click or RETURN.
EDIT
I've created a super simple page that will log to the android log file whatever input events are seen on the page. http://imaiparrott.org/bugs/input.html. Go there in your Android browser and play around with input events and view them in adb logcat. From what I can see, my trackball doesn't get registered at all for any events. You might be out of luck...
On the other hand, depending on what exactly your site is, I can think of one hacky way to do it... The trackball focuses DOM objects that are focusable. If you have the kind of page that doesn't need standard DOM objects being focusable (like a game perhaps) then you could create a couple sort of 'hidden' DOM objects and listen to the DOMFocus events for them. With a tricky combination of events from that you could figure out which trackball event was fired.