8

I am trying to detect german umlauts with a soft keyboard. To recognize the entered characters I use the method onKeyUp(). But this method is not executed for German umlauts.

Is there a way for me to recognize them?

deHaar
  • 17,687
  • 10
  • 38
  • 51
Flipp95
  • 81
  • 2

1 Answers1

2

In general it is not a good idea to check for language specific characters with KeyListener. For this use case it is better to use TextWatcher.

object : TextWatcher {

    override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
        val umlaut = "\u00FC"
        if (!s.isNullOrEmpty() && s[count - 1].toString() == umlaut) {
            // Do your thing
        }
    }

    ... 
}