When the on-screen keyboard is up the app still receives input events from the controller. The app needs to ignore these, so the on-screen keyboard can handle them instead. i.e. so the controller navigates the keyboard, not the app behind.
So, how can I tell that the on-screen keyboard is in use, so I can ignore controller input events?
Input events from the remote are fine because the OS handles these silently when the keyboard is up and never passes them on to the app at all. The result of this is you can use the remote to navigate the on-screen keyboard, but not the controller.
On other Android apps I can detect that the keyboard is up because the visible screen size has just shrunk, but as the FireTV on screen keyboard is an overlay it doesn't trigger this code.