I set android:imeOptions="actionSearch"
on an EditText. I was testing on the emulator, and pressing the physical enter key did not work as I expected. I thought it would have the same effect as clicking the Search button on the on-screen IME, but it had no effect.
I edited the code like below, and it made pressing the physical enter key triggered the action, but it did not hide the on-screen IME like the Search button. I think I could find a way to manually hide the on-screen IME, too, but I am not sure if this is the right approach. Basically, what I want is "physical enter key = on-screen IME Search button". Instead of manually repeating the Search button's behaviour, isn't there a way to tell the system to treat the two in the same way?
setOnEditorActionListener {
view, actionId, keyEvent ->
if(actionId == EditorInfo.IME_ACTION_SEARCH ||
keyEvent.keyCode == KeyEvent.KEYCODE_ENTER)
{
//do action
true;
}