I have on one screen text input and on back button...
# compose
j
I have on one screen text input and on back button press i would like to intercept it and run some function. Could not make it with BackHandler. Is there any chance to run custom function on hardware back button press?
c
That’s what BackHandler is for. What do you mean you couldn’t make it with BackHandler?
☝️ 1
j
I want to run function when keyboard is up and press back button to intercept it. But this function never runs.
c
Ah ok. When the keyboard is up, I think the back button becomes “keyboard dismiss” (this may be device vendor-specific), so no, BackHandler doesn’t work there, because there is no back button press. Depending on exactly what you want to do you might try `KeyboardActions`: https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/KeyboardActions or
onFocusChanged
modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/focus/package-summary#(androidx.compose.ui.Modifie[…]cusChanged(kotlin.Function1)