JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.9k stars 1.16k forks source link

Can't handle onKeyEvent in iOS with virtual screen keyboard #4331

Open dima-avdeev-jb opened 6 months ago

dima-avdeev-jb commented 6 months ago

Describe the bug Modifier.onKeyEvent doesn't works with virtual iOS keyboard. (It works only with physical keyboard in simulator)

Affected platforms

Versions

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

acmpo6ou commented 4 months ago

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.

acmpo6ou commented 4 months ago

I have investigated the issue for Android further, and wrote an answer on Stack Overflow: https://stackoverflow.com/a/78426786/11004423

okushnikov commented 2 weeks ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.