UDP keyboard. Any better approaches?

  android, c++, python, virtual-keyboard

Main motive is to send charecters over the network and have them typed on the phone… User friendlyness is not a concern coz im the only one who is gonna be using this..

I wanted to avoid making apps for this .. so I pretty accomplished this through python and adb in termux, But adb shell input text xyz was way too slow. So I gave in and decided to make a udp server app with java..
Tried 2 methods:

Instrumentation m_Instrumentation = new Instrumentation();
m_Instrumentation.sendKeyDownUpSync( KeyEvent.KEYCODE_B );

and via InputMethodService/InputConnection..

Former required permissions that needed root and the latter just raises NullPointerException on the InputConnection object.

So is there any better, more obvious approach to this problem?
Im willing to use any platform..(Java / Python / C++)

Source: Windows Questions C++