To deal with lost keyboard (after switching away from LXDE and switching back) I put the "Fix LXDE keyboard" icon on my desktop for easy access. I could make a script that constantly checks for lost keyboard focus, but it would probably be a drain on the battery...