1

I would like to ask if someone could give me a simple explanation of the KeyEvent.ACTION_MULTIPLE in Android and an example when it is triggered.

Here -> http://developer.android.com/reference/android/view/KeyEvent.html#ACTION_MULTIPLE it says that: When interacting with an IME, the framework may deliver key events with the special action ACTION_MULTIPLE that either specifies that single repeated key code or a sequence of characters to insert.

What does it mean reapeted key code? That a key is pressed and held down? Sorry but it is not really clear to me cause I am not English and I am new in the Android developing.

Thanks for the attention!

EDIT: So the event is triggered only when an arrow key of the keyboard is pressed and held down? As the user whose answer was accepted says here -> What triggers (or generates) KeyEvent.ACTION_MULTIPLE?, is it correct?

enter image description here

Community
  • 1
  • 1
tonix
  • 6,671
  • 13
  • 75
  • 136
  • That was exactly where I found that piece of text I have posted, sorry i forgot to post the link. I didn't understand however their explanation... – tonix Jun 19 '14 at 12:15
  • see this http://stackoverflow.com/questions/15286312/what-triggers-or-generates-keyevent-action-multiple – Droidekas Jun 19 '14 at 12:18
  • "presumably the event is generated for key auto-repeat when the user holds down an arrow key.", so this means that the event is triggered only when the user uses a keyboard and holds down an arrow key? Please check my edit – tonix Jun 20 '14 at 11:48

1 Answers1

0

Your question made me curious :)..so I tried this code,and I was able to repeat this with a few keys.eg. Backpress:when you press this key continuously,the IME starts deleting one word a ta time instead of one letter.similarly,it is possible determine multiple presses of keys which support such action. This again depends on the IME.This would also be useful majorly from an IME app's Point.You cannot often replicate it is because long press usually triggers a different character. Another point would be that KeyCodes are also inputted from the presence of a hardware keyboard.So this can come up and depends how you handle it. While the http://developer.android.com/reference/android/view/View.OnKeyListener.html says that this action is triggerred only hardware keyboards,it worked with my software keyboard too.ALTHOUGH they are not expected to do so.I guess you can say that this would into picture when you use a hardware keyboard

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    EditText et = (EditText) findViewById(R.id.checkText);
    KeyListener listener = et.getKeyListener();
    Log.d("tag", listener.toString());
    et.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            Log.d("tag", event.getAction()+"event");
            return true;
        }
    });
}
}
Droidekas
  • 3,464
  • 2
  • 26
  • 40