Sorry for the late response(turned of the notification for this post by mistake)
Here's the snippet i'm using
String command = "adb shell input text \""+newData+"\"";
Process result = Runtime.getRuntime().exec(command);
You can mix and mach these commands whatever fulfills your requirements.
@Priyank_Shah I don't use the integer values i.e. 84 you used. I always pass the string constant android site provided.
adb -s input keyevent KEYCODE_SEARCH
and the key event for the buttons other than the characters don't work always.
I prefer
element.sendKeys(text+"\n")