1

I have an external device I am using, which tells my android device it is a keyboard. However, it only has a few buttons and is not actually a full keyboard. In Jetpack Compose, none of my text input fields will show the on-screen keyboard when focused because the device thinks the external keyboard is going to handle it. How do I force my app to open the on screen keyboard when the text fields are focused, even with the presence of an external keyboard? I am hoping there is an app or device level setting I can use. I would rather not have to attach code to every text input field in the app.

What I have tried that doesn't work:

val localFocus = LocalFocusManager.current
val focusRequester = remember { FocusRequester() }
val keyboardController = LocalSoftwareKeyboardController.current

TextField(
...
    keyboardOptions = KeyboardOptions(
        keyboardType = KeyboardType.Ascii,
        autoCorrect = false,
        imeAction = ImeAction.Search
    ),
    keyboardActions = KeyboardActions(
        onNext = { localFocus.clearFocus() },
    ),
    modifier = Modifier.focusRequester(focusRequester)
)
LaunchedEffect(focusRequester) {
    focusRequester.requestFocus()
    keyboardController?.show()
}

toshiomagic
  • 1,335
  • 1
  • 12
  • 39

0 Answers0