TL;DR: to fix it on OSX run in the terminal:
defaults write -g ApplePressAndHoldEnabled -bool false
Details:
I had this issue for years on OSX in Android Studio and in all the other Intellij Based apps (AppCode, WebStorm, IntelliJ Idea, etc): after some time the editor loses focus and it's not possible to edit anymore until switch to another window or clicking on a status bar. Usually it happens couple of times per day and although I'm a big fan of IntelliJ stack it was very annoying. That's why I decided to provide a detailed explanation how to get rid of this problem and hope my fix might help someone since I can't find a definitive solution around.
As I found on the net potential solution is to use Oracle JDK as an IDE boot JDK but it has problems with fonts and not acceptable in my case.
Using instructions in https://intellij-support.jetbrains.com/hc/articles/206544879 I've tried to work-around this problem with the latest IntelliJ JDK (112 b801) from: https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbsdk8u112b801_osx_x64.tar.gz
To set it up just use Help > Find Action...

and select the JDK downloaded from the above mentioned location

I had the feeling that issue became less frequent but it still took place at least once per day.
After some time the link mentioned below inspired me to try to experiment with the system OSX setting which blocks keyboard input after press and hold a single key. Many thanks to Jonathan Ruckwood's observation here:
https://youtrack.jetbrains.com/issue/IDEA-152818#comment=27-1434006
By default OSX prevents keys repeat after press and hold (see details here: https://discussions.apple.com/thread/5038771?tstart=0). You can easily see it in any text editor (except Emacs, terminal and maybe some others) when press any letter key it won't produce several characters in contrary to arrow keys and some other keys which can be repeated. This behaviour can be changed. I was thinking about some potential interference during keyboard blocking between the system and IntelliJ IDE and tried the following command to prevent key repeat block (it could be changed back to true at any time):
defaults write -g ApplePressAndHoldEnabled -bool false
After applying this command the Android Studio or other IntelliJ IDE should be restarted. Before I had such keyboard blocking errors several times per day and now after 3 days there is no any sign of this nuisance. Fingers crossed... In any case I think it's better now than before. One additional configuration change I did is using custom boot JDK (it did not work alone but maybe it works together with ApplePressAndHoldEnabled parameter).
Having that said I believe it's a bug and must be fixed to work on OSX out of the box without modifying default settings and boot JDKs. This way please vote for the fix here:
https://youtrack.jetbrains.com/issue/IDEA-152818#comment=27-1434006