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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:58:08+00:00 2026-05-19T10:58:08+00:00

The question: I’m overriding the GWT TextInputCell.onBrowserEvent() method to try and apply filtering on

  • 0

The question:

I’m overriding the GWT TextInputCell.onBrowserEvent() method to try and apply filtering on the characters that are typed in to the field. How can I can’t get the actual character that the user typed in on a keydown event?

What I’ve tried:

I can use the NativeEvent.getKeyCode() method to get the key code, but this is insufficient because I want to know the specific character they typed in, so I can compare the character to a regular express. As I understand it, the keyCode just tells me the key they typed on the keyboard, so I can’t discriminate between a capital ‘A’ and a lowercase ‘a’. I can also grab the value from the InputElement on the keyup event, but this is too late, because the character has already been rendered to the UI element.

When I call NativeEvent.getCharCode() it returns 0 for any character I type. I tried this on Chrome and on Firefox. Why does getCharCode() always return 0? Is this a bug?

For example, here is what I tried and the values I get when I type in the number ‘1’ on the keyboard:

event.getKeyCode() - 49
event.getCharCode() - 0
Character.toChars(event.getCharCode())[0] - (a box character because charCode was 0)
String.valueOf(Character.toChars(event.getCharCode())) - (a box character because charCode was 0)
String.valueOf((char) event.getKeyCode()) - 1

Update:

OK, so I see that I need to capture the keypress event and not keydown, but I print off every event.getType() value for every event that occurs as I type and I never see a single keypress event triggered. So my updated question is, why isn’t the keypress event occurring? And if I can’t capture it in the TextInputCell.onBrowserEvent() method, is there a different way to capture it for a TextInputCell.

  • 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-19T10:58:09+00:00Added an answer on May 19, 2026 at 10:58 am

    So it turns out that the AbstractCell takes a list of strings that represent the “consumedEvents”. This basically limits the event types that can be handled by the child cell classes. TextInputCell passes in the change and keyup event types. The AbstractInputCell adds focus, blur, and keydown. Therefore, TextInputCell is not able to handle keypress native events.

    I ended up creating a near-exact copy of the TextInputCell in my own project and adding the keypress type to the constructor. I was then able to grab the events and do the filtering that I wanted to do. I’m going to create a request in GWT to add this functionality into the TextInputCell.

    I also created a feature request to add this functionality to GWT: http://code.google.com/p/google-web-toolkit/issues/detail?id=5891

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

Sidebar

Related Questions

QUESTION How can I create a MySQL table so, that a field's default value
Question: Is it possible to write a C# dll that can be pinvoked ?
Question Can I build a image database/library that has an e-commerce style checkout system
Question Is it possible to stop a Message Driven Bean (programmatically), so that it
Question context: let say that there is some really important row in config/locales/en.yml that
Question: I wrote a method to retrieve a SQL result as a list of
Question is similar to this one How to write a MySQL query that returns
Question concerning the JMM and the semantics concerning volatile fields that are written to
Question How can I remove empty xml tags in PHP? Example: $value1 = 2;
Question: I have written a console program that uses the SQL server 2005 web

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.