Help with virtual variable

Im new to the Home Remote and struggling figuring out how to go about sending text to Kodi. I have figured out most of it, but not sure how to complete the setup.

This json command is working and tested.
“SendText”:’{“jsonrpc”:“2.0”,“method”:“Input.SendText”,“params”:{“text”:"’ + virtualkeyboard + ‘",“done”:false},“id”:0}’,

I made a virtual device variable called virtualkeyboard, this variable is binded to a text box, this text box is set to send on unloaded.

In my kodi script file, I have a var defined as var virtualkeyboard = ???, not sure how I define this var to be connected to the text iI made earlier. Not sure, there also is probably a better way to do this.

If I change the var virtualkeyboard = “anytext”, it sends the anytext, so I have verified the json statement works correctly.

I have tried to define the virtual device many ways, sometimes I get undefined, {Object, Object} to send to kodi, but can seem to link it to the text on the virtual keyboard. Plain text always works correctly.

Any suggestions would be helpful.