I am new to android. I am trying to figure out how exactly does a soft-keyboard on an android device work ? Especially what exactly is the 'behind the scenes' process that takes place ? 

My actual concern is to find out how exactly key-loggers on android devices tap key-strokes so that I could figure out how can such an attack be mitigated. Hence I am looking for details in that respect and to that depth.

Any inforamtion on resources on the same will be highly appreciated.