I\'ve attached an OnKeyListener to an EditText. I\'ve overrode the onKey handler to capture a KeyEvent.
When a user hits the enter key (either their computer enter
I debugged and what worked for me was that,
editText.setOnKeyListener(View.OnKeyListener { view, i, keyEvent ->
if (i == KeyEvent.KEYCODE_ENTER && enterAsSend && (keyEvent.action == KeyEvent.ACTION_UP || keyEvent.action == KeyEvent.ACTION_DOWN)) {
//Do stuff
}
return@OnKeyListener true
}
false
})
and checkout your Editext that android:inputType="textNoSuggestions"
because the first click of enter key gives us the suggestion from the dictionary.