I want to do some stuff on soft keyboard enter key press. See my code and output below. It executes twice, but I want it to be executed only once. How to fix it?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txt = (EditText)findViewById(R.id.txt);
txt.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
Log.e("test","--------- on enter");
return false;
}
return false;
}
});
}
Go to More options > Settings > Chats . Turn Enter is send on or off.
All Microsoft keyboards uses ↵ a thin turned arrow with a sharp 90° corner. This is the most popular graphic symbol used. If a keyboard use a return arrow symbol, it's usually with sharp 90° corner like this.
The first is in Settings (tap the three dots when viewing your conversations) > Scroll down to Sending and uncheck Send using Enter. If you're having the smiley issue, keep scrolling down to the bottom and tap Keyboard. In that menu it says Smiley or Enter - make sure yours is set to enter. Hope that helps.
The best way possible:
if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
Log.d(TAG, "enter_key_called");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With