Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dima-avdeev-jb opened this issue Feb 19, 2024 · 3 comments
Closed

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

dima-avdeev-jb opened this issue Feb 19, 2024 · 3 comments
Labels
bug Something isn't working ios

Comments

@dima-avdeev-jb
Copy link
Contributor

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

@acmpo6ou
Copy link

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
Copy link

acmpo6ou commented May 4, 2024

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

@okushnikov
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios
Projects
None yet
Development

No branches or pull requests

3 participants