iOS Question iOS soft keyboard character and BACKSPACE, ENTER detection

Arf

Well-Known Member
Licensed User
Longtime User
I would like to intercept characters typed into the keyboard, but I also need to intercept if backspace and enter are pressed.
I am currently invoking the keyboard by setting focus on a textview and can intercept individual characters, but not the back/enter buttons.
Any suggestions as to how I can accomplish this?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This seems to work:
B4X:
Private Sub TextView1_TextChanged (OldText As String, NewText As String)
    If NewText = "~" Then Return
    If NewText = "" Then
        Log("backspace")
    Else
        Dim c As String = NewText.SubString(NewText.Length - 1)
        Log($"new char: ${c}, codepoint: ${Asc(c)}"$)
    End If
    Dim field As B4XView = Sender
    Sleep(0)
    field.Text = "~"
End Sub
 
  • Like
Reactions: Arf
Upvote 0
Top