I'm not sure I have understood exactly what you are doing with those multiple virtual 3X3(?) keyboards but I think I get the general idea.
You want to push a key on the keyboard, pushing it once moves that value from 0 to 1, pushing it again moves it from 1 to 2, and again, 0 to 1.
By hitting enter you want to store that value somewhere after all the other values of the previous pushed buttons?
I'd do hit like this:
On layout startup:
Set Global Text Variable RESULT = "" (empty)
on button "A" pressed:
if Global Number Variable A = 0 set it to 1
Sub event: Append Variable RESULT with: ""&VariableA (1)
if Global Number Variable A = 1 set it to 2
Sub event: Append Variable RESULT with: ""&VariableA (2)
if Global Number Variable A = 2 set it to 0
Sub event: Append Variable RESULT with: ""&VariableA (3)
on button "B" pressed:
etc..