Get single keystrokes using TextChanged

bielec

Member
Licensed User
Longtime User
I had some difficulty in getting isolated keystrokes and I eventually came up with the attached method which uses TextChanged.

The code is restricted to the absolute minimum to prevent confusion. I personally get confused with illustrative pieces of code which contain all kinds of extraneous functionality.

The code has some shortcomings eg. it does not support delete or backspace so these and other events would need to be trapped by further code.

.... and if someone can tell me how to attach the code, I will attach it. I thought Manage Attachments then upload attachments did it, but no.
I just get "Invalid file" ?

Anyway, I have edited this post to show the simple code....
Basically you tap one text box to bring up the keyboard and the single keystrokes appear in the other box the instant they are keyed.

Sub Globals
Dim EditText1 As EditText
Dim EditText2 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
EditText2.TextSize=70
EditText1.TextSize=14
ToastMessageShow("Tap window to show keypad", True)
End Sub

Sub EditText1_TextChanged (Old As String, New As String)
EditText2.Text= New.Substring(New.Length-1)
End Sub
 
Last edited:
Top