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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:16:32+00:00 2026-05-18T09:16:32+00:00

I have a web page and I need to intercept all keypresses before they

  • 0

I have a web page and I need to intercept all keypresses before they get dispatched to whatever element in the dom has the focus. When the user types something like ~goto:/index.html: (which in fact will come from a barcode scanner) I need to capture the key presses after the ~ to parse them once I get to the second :. I’ve managed to get something with the $(document).keypress() as follows:

$(document).ready(function() {
  $(document).keypress(function(e) {
    // do the processing here and 
    // return false when ignoring keystrokes
  });
});

The problem is that I get the keypress after it has gone to the focussed element. Anyway to get it before so that I can in fact reject it?

  • 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-18T09:16:33+00:00Added an answer on May 18, 2026 at 9:16 am

    You will probably have better luck with keydown it should fire before the event

    also do this

    $(document).keydown(function(e) {
        e.preventDefault();
    });
    

    calling preventDefault will stop normal process of the key press. Actually, you may be able to stay with keypress and just use the preventDefault to finish your interception needs.

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

Sidebar

Related Questions

I have a web page with some links, and I need to intercept the
I have a web page written in ASP.NET and I need to retrieve the
I have a simple web page that till now didn't need any login. It
I have an ASP.NET web page that displays a variety of fields that need
I have a friend who is need of a web page. He does interior
I have a long URL on a web page in Windows that I need
I need to play .vox files on my web page. Does anyone have any
So I have this web page I need to debug in IE (9). I'd
I need to get the contents of a HTML page from the Web, but
I have an ASP.net page. When I am closing the webpage I need to

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.