Monday, April 16, 2012

android WebView: Handle arrow keys in javacript

I have a simple WebView application which I want to control with the keyboard.
Is it possible to catch arrow keys in javascript?



I have tried the following code without any luck:



function handleArrowKeys(evt) {
console.info('key');
}

document.onkeyup = handleArrowKeys;
document.onkedown = handleArrowKeys;
document.onkepress = handleArrowKeys;


javascript is enabled in the webview



WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);




No comments:

Post a Comment