views:

54

answers:

1

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?

+1  A: 

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.

Moncader
I tried with mouse and keyboard events but nothing seems to be mapped to trackball...
Jaime Soriano
I've updated the answer with many more details.
Moncader
Nice test page :) I had done something like that, but as you said, no luck... About the focus changes, I also tried that, but it seems that trackball doesn't go throught all focusable items...
Jaime Soriano