简体   繁体   中英

Android- What is the return key called?

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.

在此处输入图像描述

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

Thanks!

That should be keycode_enter / 66 (0x00000042)

see List of keycodes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM