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

The Archive Base Latest Questions

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

I am using a small script that triggers the next/previous links on the page

  • 0

I am using a small script that triggers the next/previous links on the page when an arrow key is pressed. I am trying to prevent this from happening when a user is typing in my search input form (maybe they spelled their query wrong and want to use the arrow keys to fix).

Here is what I’m working with:

var $j = jQuery.noConflict();

$j(function(){
    $j('.n').click(function() {
        location.href = $j(this).attr('href')
    });
    $j('.p').click(function(){
        location.href = $j(this).attr('href')
    });
});

$j(':not(input)').keydown(function(event) {
    if(event.keyCode==39) {
        $j('.n').trigger('click')
    }
    if(event.keyCode==37) {
        $j('.p').trigger('click')
    }
});

And the HTML is basically just a form with an input field. The trigger still goes even when the cursor is in the input. I’m not sure what I’m doing wrong. Any help is much appreciated!

  • 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-25T11:22:25+00:00Added an answer on May 25, 2026 at 11:22 am

    the event is bubbling up from the input through the rest of the document.

    In your event try logging out event.trigger :

    $j(':not(input)').keydown(function(event) {
      console.log(event.trigger);
      // REST OF FN
    

    I bet it’s not an HTMLInputElement

    One solution, try binding on inputs and stopping the event propagation :

    $j('input').keydown(function(event) {
      event.stopPropagation();
    });
    

    See if that helps.

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

Sidebar

Related Questions

I currently have a small Python script that I'm using to spawn multiple executables,
I'm using a small Python script to generate some binary data that will be
I'm currently writing a small script using pygame, but I don't believe this question
Basically, what I'm trying to do is simply make a small script that accesses
I've got a small script that detects if the user is using a certain
I have a small vim script that queries Google to insert links in markdown-formatted
I'm trying to write a small Python script that will get query results from
I have a small bash script that greps/awk paragraph by using a keyword. But
I try to make a small script, using c shell, that will take a
I have a small script which im using to test PHP mail(), as below:

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.