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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:42:17+00:00 2026-06-08T12:42:17+00:00

itemBox.addKeyUpHandler( new KeyUpHandler() { public void onKeyUp( KeyUpEvent event ) { String currentValue =

  • 0
        itemBox.addKeyUpHandler( new KeyUpHandler()
        {
            public void onKeyUp( KeyUpEvent event )
            {
                String currentValue = itemBox.getValue().trim();
                // handle backspace
                if( event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE )
                {
                    if( "".equals( currentValue ) )
                    {
                        doTheJob( );
                    }
                }
            }
        } );

Expect behavior:
when the textbox is empty, then i hit delete, will run doTheJob();

Current behavior:
when there is one character, i hit delete, it will trigger doTheJob();

In other word, is there any way i can get textbox content before i hit delete key?
I tried to used a var to hold the last value, but it needs to register another listener and the impl is not so effective.

Thanks for your input.

////////////////////Edit //////////////////////

use KeyDownHandler did solve the above problem, however lead to another problem:
i use itemBox.setValue( “” ); to clear the textbox but it will always have a comma there.

        itemBox.addKeyDownHandler( new KeyDownHandler()
        {
            public void onKeyDown( KeyDownEvent event )
            {
                // handle backspace
                if( event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE )
                {
                    String currentValue = itemBox.getValue().trim();
                    if( "".equals( currentValue ) )
                    {
                       doTheJob();
                    }
                }
                // handle comma
                else if( event.getNativeKeyCode() == 188 )
                {
                     doOtherJob();
                    //clear TextBox for new input
                     itemBox.setValue( "" );
                     itemBox.setFocus( setFocus );
                }
            }
        } );
  • 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-08T12:42:19+00:00Added an answer on June 8, 2026 at 12:42 pm

    after

    itemBox.setFocus( setFocus );
    

    prevent event bubbling with

    event.preventDefault();
    event.stopPropagation();
    

    So the event will be canceled before comma is added to the textbox content.

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

Sidebar

Related Questions

I have the following business objects: public class ItemCategoryBO { public string ItemCategory {
I have an: .itembox { class, where many items in a directory type website
I am trying to program a ListBoxItem Selected event in code because I need
I'm stucking with some design techniques where I want to make image item box
I'm trying to do something simple, but somehow it doesnt work for me, here's
I have a form that i am trying to submit after the page loads
The following rule has no content (is empty) when I view the styles in
I have a page with 4 TextBoxes. Each time pressing on the TextBox I
In this scenario (your basic catalog), there are multiple <div> s, each containing an
I'm trying to align small boxes in a row. These boxes have something like

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.