Android- What is the return key called?

1k Views Asked by At

I am currently creating a key listener that runs code when the enter key is pressed. It works on my actual pc keyboard when I run the enter key. The code looks something like this:

        inputtedMachineKey.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if (event.getAction() == KeyEvent.ACTION_DOWN &&
                    keyCode == KeyEvent.KEYCODE_ENTER) {
                Toast.makeText(SelectMachineKeyActivity.this, "Enter Key Hit!", Toast.LENGTH_SHORT).show();
            }
            return true;
        }
    });

Problem is that KeyEvent.KEYCODE_ENTER is only working for the enter button on an actual keyboard. For the emulated keyboard, when the return/enter key is pressed, nothing happens.

enter image description here

Does anyone know the keycode for the enter button for the image I posted?

Thanks!

1

There are 1 best solutions below

2
On

That should be keycode_enter / 66 (0x00000042)

see List of keycodes