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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:52:27+00:00 2026-06-17T19:52:27+00:00

I mostly fixed the problem with these lines in dispatchKeyEvent: byte[] cmdLeft = {

  • 0

I mostly fixed the problem with these lines in dispatchKeyEvent:

byte[] cmdLeft = { (byte) 27, (byte) '[', (byte) 'D' };
byte[] cmdErase = { (byte) 27, (byte) '[', (byte) 'P' };


mSession.appendToEmulator(cmdLeft, 0, cmdLeft.length);
mSession.appendToEmulator(cmdErase, 0, cmdErase.length);

The only problem now is that if I select the editText and hit delete then one character is deleted but two appear to be on screen. so if I write enable and hit delete it will change to enab but what would actually be sent is enabl

I overrode dispatchKeyEvent, and it kind of works. If the editText is selected, the terminal deletes characters over serial now, so that is a good step. However the main problem still exists that if the terminal is selected itself, weird little boxes are written to the screen instead of deleting a character. Well one is written, and if I keep pressing delete it stays at that one box, but next time I type the amount of deletes I pressed comes up as boxes. It’s very odd…

It’s like it is just overridden for the edittext and not for the terminal.

Weird little boxes in all their glory:

Enter image description here

public boolean dispatchKeyEvent(KeyEvent event) {
    if (event != null && event.getAction() == KeyEvent.ACTION_UP) {

        return false;
    }
    if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {

        try {
            sendOverSerial("\b".getBytes("UTF-8"));
        }
        catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return super.dispatchKeyEvent(event);
};

I am connecting to a terminal emulator using a library in android, this connects to a serial device (a switch) and shows me sent/received data. I send data over the connection via a text box below the terminal or by typing in the terminal itself and hitting enter on the keyboard in both cases. It will only ever be a soft keyboard that is used. If I send an incorrect string I am in an unrecoverable state due to not having a delete key implementation. Backspace in my editTxt works fine, I just want it to work when the terminal is highlighted and I am writing in that.

At the moment if I press delete a little odd box character comes up and nothing else happens, I get an exception in the log some times(https://i.stack.imgur.com/xNyrZ.png). What I want to know is how to I go about changing the delete keys functionality so that when I press it I can send a delete character like this but also retain the ability to delete characters in the edittext box etc:

sendOverSerial("\b".getBytes("UTF-8"))

This sends a correct back space, I just need to incorporate it.

But the soft-keyboard doesn’t seem to register key presses? i keep getting a keycode of 0 and only enter will work.

I am currently trying out https://stackoverflow.com/questions/4…62035_11377462, but any other suggestions would be great, as about 10 suggestions haven’t worked so far. My backspace wouldn’t be associated with an editText, but a terminal View. I can’t even detect the delete key being pressed.

  • 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-06-17T19:52:28+00:00Added an answer on June 17, 2026 at 7:52 pm

    It looks like the terminal control you are using must be consuming the KEYCODE_DEL instead of letting it propagate to the window and it must be sending a different char to the remote end instead of \b. So when your edit text is focused your dispatchKeyEvent is handling the press – but you don’t see it when the terminal has focus. Have you confirmed that the even handler is firing via debugger when the terminal has focus? You didn’t say which library you are using for the terminal, but I’d look at that and see if you can set a key handler or something.

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

Sidebar

Related Questions

I need a JTextField that only accepts positive integers as input. My implementation mostly
I have encountered a problem in my program that has me somewhat stumped. I
I understand the differences between CHAR and VARCHAR, one being fixed-length and the other
I've got a mostly cosmetic problem. I'm creating four plots using the ggplot2 library
I have an Activity that mostly consists of a large MapView. On top of
I have a problem using a HolidayCalendar. It seems that the calendar is simply
I look for a LayoutManager that has fixed height JButtons that expand in width
I am writing a class library that wraps different objects (mostly device drivers for
Given a problem that is encoded using Z3's reals, which of the statistics that
Mostly we upload things by an upload field in the HTML and uploads the

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.