Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6064531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:17:26+00:00 2026-05-23T09:17:26+00:00

On an EditText component, I’m trying to set a KeyListener in order to catch

  • 0

On an EditText component, I’m trying to set a KeyListener in order to catch the ENTER key (for form validation).

    text.setKeyListener(new KeyListener() {

        @Override
        public boolean onKeyUp(View view, Editable text, int keyCode, KeyEvent event) {
            return false;
        }

        @Override
        public boolean onKeyOther(View view, Editable text, KeyEvent event) {
            return false;
        }

        @Override
        public boolean onKeyDown(View view, Editable text, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                onKeyEnterPressedListener.onKeyEnterPressed(AKText.this);
                return true;
            } else {
                return false;
            }
        }

        @Override
        public int getInputType() {
            return 1;
        }

        @Override
        public void clearMetaKeyState(View view, Editable content, int states) {

        }
    });

The problem is that whenever I type in the EditText using the keyboard, all the keys are ignored and it’s ignoring my keystrokes. However, the softpad on the emulator’s device is working.

How to fix this please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:17:26+00:00Added an answer on May 23, 2026 at 9:17 am

    I would use the TextWatcher class instead:

    private TextWatcher tw = new TextWatcher() {
        public void afterTextChanged(Editable s){
    
        }
        public void  beforeTextChanged(CharSequence s, int start, int count, int after){
          // you can check for enter key here
        }
        public void  onTextChanged (CharSequence s, int start, int before,int count) {
        } 
    };
    
    EditText et = (EditText) findViewById(R.id.YOUR_EDITTEXT_ID);
    et.addTextChangedListener(tw);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In edittext, after typing 'Enter' key, system make a new line inside it. I'd
I want to simply set the height of an EditText component to be 50%
I have a EditText and button aligned to parent's bottom. When I enter text
I am trying to make the editText that shows the text but not as
I have an EditText and a Button set next to each other on the
In the layout you can set the EditText widget to be non-editable via the
How can I enter only alphabets in EditText in android?
I am trying to get the value of a EditText in a dialog box.
I have a EditText that I have set to invisible by default. I would
I'm using an EditText in which the text is filled programaticaly, when users performs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.