We don't have a way to do this currently. The app doesn't know if the keyboard is showing or not.
In addition to the back key press, you could end up in this state in a number of ways:
1. The user manually hides the keyboard by tapping on ▼
2. The user connects a hardware keyboard to the system which dismisses the soft keyboard
I would like to understand the usecase better. Why do you want to clear focus when the user dismisses the keyboard?
We don't have a compose API to do this, but there is a way to check if the keyboard is visible or not, but this is only available after R:
LocalView.current.rootWindowInsets?.isVisible(WindowInsets.Type.ime())
You could check this periodically and then call
LocalFocusManager.current.clearFocus()