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

  • SEARCH
  • Home
  • 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 3351494
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:54:56+00:00 2026-05-18T01:54:56+00:00

hi where to use onKey and onKeyUp/Down event in android. e.g. i have one

  • 0

hi
where to use onKey and onKeyUp/Down event in android.

e.g. i have one textview . when user pressed any key i want to display that character in textview,
In this case which event(above) is used.

PLEASE explain with EXAMPLE 

Or give some other example that get the key event and print in edittext or some other.

Thanks in advance…

  • 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-18T01:54:56+00:00Added an answer on May 18, 2026 at 1:54 am

    pls refer the following code

    public class Demo extends Activity
     {
    
        /**
         *  Variables & Objects Declaration
         * 
         */
    
    
         EditText  et;
    
         private static Context CONTEXT;
        /** Called when the activity is first created. */
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
            setContentView(R.layout.main);
            et =(EditText)findViewById(R.id.header_text02);
            }// end of OnCreate
    
        @Override
        public boolean onKeyDown(View arg0, Editable arg1, int arg2, KeyEvent arg3) {
            // TODO Auto-generated method stub
            Log.v("I am ","KeyDown");
               switch (keyCode) {
                       case KeyEvent.KEYCODE_A:
                       {
                           //your Action code
                           et.setText("A");
                          return true;
                        }
                          case KeyEvent.KEYCODE_B:
                       {
                           //your Action code
                           et.setText("B");
                          return true;
                        }
                       // similarly write for others too
            }
    
    
    
            return true;
        }// End of onKeyDown
    
    
    
        @Override
        public boolean onKeyUp(View arg0, Editable arg1, int arg2, KeyEvent arg3) {
            // TODO Auto-generated method stub
            Log.v("I am ","KeyUp");
                et.setText("KeyUp");
            return true;
        }// End of onKeyUp
    
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 fields that can be use in row area. One of them
I am implementing a datastructure and want the user to be able to use
I have a template class where I want to use objects of that class
How do I use key_down event in my vb.net? I have seen so many
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: user clicks the link on a webpage - boom! load of files
Use case: I've just entered insert mode, and typed some text. Now I want
Use Case When a user goes to my website, they will be confronted with
myEdit1.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { myEdit2.setText(); return
Using Application.OnKey <key>, <procedure> , I can cause Excel to run <procedure> whenever <key>

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.