The Android SDK doesn’t provide a straightforward way to be notified if the soft keyboard is open or closed. Thankfully there are workarounds posted on Stack overflow.

I took the workaround logic and encapsulated it in a small Kotlin utility class that provides the keyboard status as an Observable. This is an useful and idiomatic example of how to convert a Listener-style callback in the Android SDK into an Observable.

And here’s how you’d use it to a hide a banner when the keyboard is open.