I am trying to override the delete button of my soft keyboard. I am able to detect the delete button being pressed but only if the EditText is empty. Is there a way of detecting if it has been pressed when there is text in my EditText? What i want to do is override the delete button to make it delete the entire contents of the EditText instead of just letter by letter. Below is the code I am using:
mEtCoupon.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// You can identify which key pressed buy checking keyCode value
// with KeyEvent.KEYCODE_
if (keyCode == KeyEvent.KEYCODE_DEL) {
// this is for backspace
Log.e("IME_TEST", "DEL KEY");
}
return false;
}
});
Is it possible to do this?