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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:04:32+00:00 2026-06-10T07:04:32+00:00

In chrome browser, when using this snippet: $(document).on(‘keyup’, function(){ alert(Hey); }); Every time I

  • 0

In chrome browser, when using this snippet:

  $(document).on('keyup', function(){
    alert("Hey");
  });

Every time I press enter in the url bar (for example when I cut and paste the url of the page itself) the event listener fires.
Why does it happen?

EDIT:

It surprised me because url bar is not in document (maybe in window?) and firefox does not have this behaviour. When I look for e.target, Chrome Inspector shows body.

I thought this could be caused by event bubbling so I tried this:

  $(document).on('keyup', function(e){
    e.stopPropagation();
    alert("Hey");
  });

But it doesn’t work.
How can I prevent it from being triggered?

  • 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-10T07:04:33+00:00Added an answer on June 10, 2026 at 7:04 am

    This happens because once you hit enter in the omnibox, the focus turns to the page. If you tried the same thing with onkeydown, the omnibox would change nothing, because as you said, it isn’t a part of the document. One way to filter the omnibox’s false event out would be to check that every keyup has a pair keydown.

    <script>
    var down = false;
    document.addEventListener('keydown', function (){
        down = true;
    }, false);
    
    document.addEventListener('keyup', function (){
        if(down === true){
            alert('It was from the page!');
        }
        else{
            alert('Omnibox. Ignore it.');
        }
        down = false;
    }, false);
    
    </script>
    

    Demo.

    Make your own HTML page and try it preferably, because PasteHTML.com stuffs it into an iframe. For it to work correctly there, click on the text first to give the iframe focus.

    Demo.
    Remember to use your mouse to focus on the omnibox and type, not a keyboard shortcut. (That fires the onkeydown event, creating a false positive)

    Update: As of Chrome 35, this doesn’t happen anymore. I don’t know which version they fixed it on, however.

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

Sidebar

Related Questions

We are capturing a visible tab in a Chrome browser (by using the extensions
I want to notify an user using Chrome browser. I need something powerful like
I have problem with items order in legend, when I using Google Chrome browser
Using browser firefox and chrome I have an input file element. <input type='file' id='tempFileInput'
When debugging browser-based apps using Google Chrome's Developer Tools, is there a way to
Following Script isn't working in CHROME browser, IE is Fine. I've changed opener.document ...
I'm trying to create an extension using this docs: http://code.google.com/chrome/extensions/content_scripts.html I want a part
I have a problem using $.getScript() on chrome. It doesn't work on chrome browser.
When using a WebKit browser (Chrome or Safari), if I try to get the
I am using Chrome browser. I have a fully transparent .png image for logo,

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.