For example, what should I do if I want a web page to get an event with a keycode value of - 1?
I tried to use webview.dispatchKeyEvent(...), but if the value of KeyEvent is not in the constant defined by KeyEvent.KEYCODE_XXX, it is converted to keyEvent.KEYCODE_UNKNOWN. That is, the event keycode value received on the page is 0
What should I do?
API 19
Both Webview and Crosswalk are okay.
In javascript add two functions to window object:
keyDownandkeyUp. In java override dispatchKeyEvent function in your main activity:Adjust this function to handle unsupported keys. The point is that once you read the key in java you can then call custom js functions without passing '0' value.
In my case I did:
where
isKeySupportedfunction checks a list of all the keys I want to handle.