It's either KeyEvent.KEYCODE_ENTER
or EditorInfo.IME_ACTION_DONE
depending on what listener you use. You need a OnEditorActionListener
for software keyboards and a OnKeyListener
for hardware keyboards:
val editText = EditText()
editText.setOnKeyListener { _, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_ENTER) {
// do something
true
} else {
false
}
}
editText.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
// do something
true
} else {
false
}
}