Not surprising. It is prohibited by Google. For security reasons, you're not allowed to send keys programmatically to other apps.
From an ADB console, you can send any key you want (and that's very useful when your screen is broken) but this console is on the PC side, not on the phone side.
With non-rooted devices, I'm almost certain there's no possibility to do it from the device (or it's a security leak and it will be fixed in the next Android release). On rooted devices, there are existing hacks (event injections) but I won't give you links because I don't support that. If you're doing an app just for you on your rooted phone, you'll find everything needed by using the Google search engine.