I am finding it difficult to say anything useful because I simply don't understand your code.
As I understand it, widget.scheduleActions() is a method which simply says "execute the actionlist of the widget. So:
a. It doesn't have any parameters. So, I don't understand what your parameter
TCPCommand ("chars:Send Test1 Text!") is doing, or trying to do.
b. It is nothing to do with TCP/IP.
So, your code:
if (keyboardState == 0) // Unshifted
CF.widget("KeyA", "Unshifted").scheduleActions(TCPCommand ("chars:Send Test1 Text!"));
else if (keyboardState == 1) // Shifted
CF.widget("KeyA", "Unshifted").scheduleActions(TCPCommand ("chars:Send Test 2 Text !"));
is effectively:
if (keyboardState == 0) CF.widget("KeyA","Unshifted").scheduleActions();
else if (keyboardState == 1) CF.widget("KeyA","Unshifted").scheduleActions();
In other words:
if keyboardState is either 0 or 1 then execute the actionlist of button "KeyA" on page "Unshifted".