compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Can't handle onKeyEvent in iOS with virtual screen keyboard

Open dima-avdeev-jb opened this issue 1 year ago • 2 comments

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

dima-avdeev-jb avatar Feb 19 '24 10:02 dima-avdeev-jb

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 avatar Apr 27 '24 15:04 acmpo6ou

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

acmpo6ou avatar May 04 '24 18:05 acmpo6ou