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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:03:26+00:00 2026-06-18T09:03:26+00:00

I want add handler or listener to button which will respond every time I

  • 0

I want add handler or listener to button which will respond every time I press key on keyboard even It’s not focus on it. How I can do that ?

  • 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-18T09:03:28+00:00Added an answer on June 18, 2026 at 9:03 am
    import com.google.gwt.user.client.Event;
    import com.google.gwt.user.client.Event.NativePreviewEvent;
    import com.google.gwt.user.client.Event.NativePreviewHandler;
    
    Event.addNativePreviewHandler(new NativePreviewHandler() {
    
       @Override
       public void onPreviewNativeEvent(NativePreviewEvent event) {
          if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_DELETE) { //needs an int code
             //fire an event to your button or call your method
    
             event.getNativeEvent().stopPropagation(); //optional
             event.getNativeEvent().preventDefault(); //optional
          }
       }
    });
    

    I was using a code like this in my onModuleLoad() method to catch the a keypress event and hide it from the browser. You can also use the

    import com.google.gwt.user.client.Element;
    
    Element as = (Element) Element.as(event.getNativeEvent().getEventTarget());
    as.getTagName();
    

    to check where it is coming from (for example tag name is “input”, “textarea”), and do your event handling based on that.

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

Sidebar

Related Questions

I want to add an event handler to an observable collection that will be
How can I add an window/event listener/handler to a wpf-window? I want to know,
I want to add an event handler to a paragraph for when any user
I want add label to every row in tableview at right side of the
I want to add an event handler to jqGrid (for the onSelectRow event) but
In QtDesigner, if i have a pushbutton and want to add a handler for
All I want to do is programatically add an onKeyDown listener to an existing
I want to add a MouseOver event handler for any tag. Let say just
I want add UIGestureRecognizerDelegate to UIWebView,but failed. if [self.view addsubView:webView]; So UIWebView is ok,but
I want add new Feed item on entity persist and update. I write this

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.