compose-multiplatform
compose-multiplatform copied to clipboard
Can't handle onKeyEvent in iOS with virtual screen keyboard
Describe the bug Modifier.onKeyEvent doesn't works with virtual iOS keyboard. (It works only with physical keyboard in simulator)
Affected platforms
- iOS
Versions
- Kotlin version*: 1.9.22
- Compose Multiplatform version*: 1.5.12, 1.6.0-rc02
- OS version(s)* iOS 17.0 simulator
- OS architecture (x86 or arm64): Arm64
To Reproduce Use this code:
@Composable
fun App() {
var keyEventsCounter by remember { mutableStateOf(0) }
Column(
Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
) {
Text("onKeyEvent counter: $keyEventsCounter")
var text by remember { mutableStateOf("type here with onscreen keyboard") }
OutlinedTextField(
value = text,
onValueChange = { text = it },
modifier = Modifier.onKeyEvent {
keyEventsCounter++
false
}
)
}
}
Expected behavior onKeyEvent should work also with onscreen keyboard
Android has the same issue, there is no way of making a composable able to receive events from on-screen keyboard. It works with a hardware keyboard, but not with an on-screen one.
I have investigated the issue for Android further, and wrote an answer on Stack Overflow: https://stackoverflow.com/a/78426786/11004423