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 3618988
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:49:20+00:00 2026-05-18T22:49:20+00:00

I am creating login screen with 2 editTexts: etUsername and etPassword. On the etUsername,

  • 0

I am creating login screen with 2 editTexts: etUsername and etPassword.

On the etUsername, user should input the username and press Enter to go to the edit text etPassword, then he inputs the password, press Enter to login. Here is my current code:

  etUsername.setOnKeyListener(new OnKeyListener() {   
   @Override
   public boolean onKey(View v, int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_ENTER)) {         
     etPassword.requestFocus();
     return true;
    } else
     return false;
   }
  });

  etPassword.setOnKeyListener(new OnKeyListener() {   
   @Override
   public boolean onKey(View v, int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_ENTER)) {         
     loginToServer();
     return true;
    } else
     return false;
   }
  });

But when I input the username, and then press Enter – the program tries to log in to the server.

In the debug mode, I saw that when I pressed Enter once (on the etUsername) then first: etUsername.onKey() is called and then etPassword.onKey() is also called !

How can I modify the code so that the ENTER event is only processed once for the current field?

  • 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-18T22:49:20+00:00Added an answer on May 18, 2026 at 10:49 pm

    Before you check which key is pressed, try adding a check for which key event occurs. I would guess that it first triggers on the key-down event, then you move focus to the second text field, and here it also triggers on the key-up event.

    See here for an example on how to check both the event type and key: Use "ENTER" key on softkeyboard instead of clicking button

    I’m not 100% sure of this, but it is worth a try 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating an application in Qt (Nokia SDK) which should hold a login screen,
HI, i am creating an login screen to my iphone application. i am sending
I am creating a login screen for an application in C#. In my login
I'm creating a login page. I want to create ASP.NET TextBox controls that have
I'm creating a control and need to pass it the current logon user as
When creating a web application, and lets say you have a User object denoting
I am creating a login page for my web application. I want to create
I am creating a login form. I am learning how to use SHA-1 to
I have written a code for a login page and user page. When the
i am creating login code for facebook connect on our site, however i cannot

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.