You can add an action to the on start of layout to download the contents of the dictionary as json.
This is what that string would look like:
{"c2dictionary":true,"data":{"right":0,"left":0,"up":0,"down":0}}
So basically you could just concatenate your data with an &:
{"c2dictionary":true,"data":{&your data&}}
SUCCESS! of a sort. Had to escape the double quotes to make it work and I apologize for my initial confusion. I've been using JSON like objects for many years without ever calling them JSON or using any special JSON processing objects. They're JavaScript objects. Easy enough to roll my own. :)
I'm now using czsx for right,left,up, down to send websocket messages. "right" "left" etc. are defined in the dictionary and Key "up" = 0 ... event triggers sprite simulate 8Direction up as per the first suggestion.
I can use the arrow keys and they work locally but do not send any websocket message. Since I haven't coded for multiplayer (all I'm doing on the server end is sending back a JSON string with right, left or whatever in it) ... using different keys to send the websocket message avoids the infinite looping.
What I'm getting now though is if I press S for up, for example, the sprite continues moving up until I click another button. I'll start looking. I think maybe there's a way to reset the value or something.