On my Samsung Galaxy tab 4 (Android 4.4.2, Chrome: 49.0.2623.105) I ran into a situation where the keyCode is always 229.
I\'ve setup a simple test for two situatio
Solution to fix it for WebView, note it handles only space character , but you can extend mapping
KeyEvent.KEYCODE_SPACE => keyCode
.
class MyWebview: WebView {
override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection? {
return BaseInputConnection(this, true)
}
override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
val dispatchFirst = super.dispatchKeyEvent(event)
// Android sends keycode 229 when space button is pressed(and other characters, except new line for example)
// So we send SPACE CHARACTER(here we handles only this case) with keyCode = 32 to browser explicitly
if (event?.keyCode == KeyEvent.KEYCODE_SPACE) {
if (event.action == KeyEvent.ACTION_DOWN) {
evaluateJavascript("javascript:keyDown(32)", null)
} else if (event.action == KeyEvent.ACTION_UP) {
evaluateJavascript("javascript:keyUp(32)", null)
}
}
return dispatchFirst
}
}