Default Simulate keyboard press from background service

a simple question: Is it possible to simulate a press on the virtual keyboard on android smartphones programatically so that the currently open app receives it?

Here is what i want to do: I want to write a background app / service that checks for gesture data send from a accelerometer via bluetooth. According to those gestures it then converts this data into different letters (A, B and so on) and "prints" them out to the current app (like WhatsApp, or simple SMS).

Is this possible?