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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:47:25+00:00 2026-05-22T01:47:25+00:00

I have a web app that I’m working on that I would like the

  • 0

I have a web app that I’m working on that I would like the user to be able to define and trigger hotkeys dynamically. I hope someone can help me out?

I’ve created a JSFiddle HERE with the pertinent HTML.

Here’s my javascript:

// Assign Hotkey (this seems to be working)
$('input.hotkey').keydown( function(event) {
var hkey = event.keyCode;
if ( hkey == $('span#hk').text()){
    alert('This key is already in use');
} else
    $(this).parent().parent().prev().find('span#hk').text(hkey);
});

// Fire Hotkey (the problem might be here?)
$(document).not('input').keydown( function (event) {
    var hkey = event.keyCode;
    if (hkey == $('span#hk').text()){
         $("span#hk:contains("+hkey+")").parent().click();
    }
});

// Play Selected Track
$('#track').live('click', function () {
    // Fake Function
    var title = $('#title', this).text();
    alert(title + ' is playing...');
});

Note: I have already used the ‘space’ and ‘left/right’ arrow keys as global hotkeys – is there a way to protect/prevent them from being assigned?

Is there a better selector to use than .not(‘input’) to prevent firing the track during input typing?

Thanks for the help!

  • 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-22T01:47:26+00:00Added an answer on May 22, 2026 at 1:47 am

    $(document).not('input') does not find all elements that are not input tags. It finds all the document nodes (of which there is one) that are not input elements (which is all one of them). All you’ve done is attached the handler to the document. Because parent elements are notified of events triggered on their descendants, all keydown events are handled by this function.

    You should make use of event.target instead:

    $(document).keydown( function (event) {
        if (event.target.nodeName.toLowerCase() !== 'input') {
            var hkey = event.keyCode;
            if (hkey == $('span#hk').text()){
                $("span#hk:contains("+hkey+")").parent().click();
            }
        }
    });
    

    The if statement means the handler does not do anything if the event originated on an input element.

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

Sidebar

Related Questions

I have inherited a working VB.NET 2.0 web app that has several User Controls
I have been support a web app that is used by a user base
I have a web app for commercial property management that needs spreadsheet-like functionality for
I have a web app that lets a client define a daily rate for
Background I have a web app that will create an image from user input.
Say I want to have a simple web app that takes some user input,
I have a web app that gathers some data from the user and saves
I have a web app that has a list of user comments. I want
I have a web app that launches an URL in other windows/tabs. I would
So I have a web app that i'm working on with a form that

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.