I need to detect every key press on either a soft or hard keyboard in EditText
. I just need to send the characters one at a time as they are pressed and don't need the final text string.
I have tried using an EditText
with onKeyPress
, but I ran into the problems here with not getting key presses with soft keyboards and TextWatcher
isn't a good option because I need each key press.
Is there any solution to know all the keypresses (including back, shift, enter... also)?
If you have an
EditText
, then you can use theTextWatcher
interface. In my code,search_edit
is anEditText
.Use
addTextChangedListener(TextWatcher watcher)
and implement TextWatcher interfaace.Implement this:
Update:
As you would like to implement Soft key listener, you can implement TextWatcher. Here is example: How to use the TextWatcher class in Android?