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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:07:01+00:00 2026-05-26T19:07:01+00:00

I do open Keyboard on Button click and i store all keypress value in

  • 0

I do open Keyboard on Button click and i store all keypress value in String but i am facing some problem like this

1. when i press CAPITAL keys then i will got 2 times char
2. when i press search and Menu button then also enter the key
3. some char i can't get like PIE

So please check this code and give me proper answer.
My Code is :

package com.indianic.phykeyboard;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class KeyboardActivity extends Activity {
    EditText mEdit;
    Boolean key = false;

    Button mKey, mMon;
    String getvalue;
    InputMethodManager imm;
    StringBuilder stringBuilder;
    TextView value;
    String ch = "";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mKey = (Button) findViewById(R.id.openkey);

        value = (TextView) findViewById(R.id.value);

        mKey.setOnClickListener(new OnClickListener() {

            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.toggleSoftInput(0, 0);
                stringBuilder = new StringBuilder();
            }
        });

    }

    public boolean onKey(View v, int keyCode, KeyEvent event) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_ENTER:
            return true;
        }
        return false;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.v("log_tag", "char : " + event.getUnicodeChar());

        if (event.getUnicodeChar() != 0) {
            int i = event.getUnicodeChar();
            ch = new Character((char) i).toString();
        }

        if (ch.length() > 0) {
            if (keyCode == KeyEvent.KEYCODE_DEL && stringBuilder.length() >= 1) {
                stringBuilder.delete(stringBuilder.length() - 1, stringBuilder
                        .length());
            } else if (keyCode != KeyEvent.KEYCODE_DEL
                    && keyCode != KeyEvent.KEYCODE_ENTER) {
                stringBuilder.append(ch);
            } else if (keyCode == KeyEvent.KEYCODE_SEARCH
                    || keyCode == KeyEvent.KEYCODE_MENU) {

            }
        }

        if (keyCode == KeyEvent.KEYCODE_BACK) {
            stringBuilder.delete(0, stringBuilder.length());
            finish();
        }

        String str = stringBuilder.toString().trim();
        value.setText(str);

        return false;
    }
}
  • 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-26T19:07:01+00:00Added an answer on May 26, 2026 at 7:07 pm

    you can try this code :

    public boolean onKeyDown(int keyCode, KeyEvent event) {
            Log.v("log_tag", "char : " + event.getUnicodeChar());
    
            if (event.getUnicodeChar() != 0) {
                int i = event.getUnicodeChar();
                ch += new Character((char) i).toString();
            }
            if (keyCode == KeyEvent.KEYCODE_DEL && ch.length() > 0) {
                ch = ch.substring(0, ch.length() - 1);
            }
            value.setText(ch);
            return super.onKeyDown(keyCode, event);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: I open the dialog, open the SIP keyboard to
I open a connection like this: Using conn as New OdbcConnection(connectionString) conn.Open() //do stuff
I sent this to KennyTM (has all the private framework headers on GitHub) but
How do I set my application to record keyboard macros. Like Shift-Alt-I would open
I would like to create an event in a button. When I click in
I've come across this while doing work on creating my own Keyboard but can't
I have this code that works ok when search button is pressed, but if
Does anyone know the keyboard shortcut in Visual Studio to open the context menu?
Open up a Rails console and enter this: 2.weeks.ago.between? 2.weeks.ago, 1.week.ago Did it give
The Open button on the open file dialog used in certain windows applications includes

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.