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

  • Home
  • SEARCH
  • 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 6574497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:16:08+00:00 2026-05-25T15:16:08+00:00

I had gotten help earlier here with what turned out to be a propagation

  • 0

I had gotten help earlier here with what turned out to be a propagation issue, but I am now trying to use HTML5 autofocus on an input and now my code breaks.

Here’s the code I’m working with:

<script type="text/javascript">
var $j = jQuery.noConflict();

$j(':not(form)').keydown(function(event) {

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

    if(event.keyCode==82) {
        $j(document).trigger(location.href = '/?random')
    }
});
</script>

Basically, I have some keyboard navigation set up. If you press R, it takes you to a random page.

I was trying to disable that functionality when a user was typing in a form/input box, for obvious reasons. This code works, EXCEPT when I try to use autofocus. If you start typing right on the pageload, and the first letter you type is R, it goes to a random page.

If another letter is typed first, then R gets entered as a normal letter. I’m kind of a newbie at this stuff, so any help is much appreciated! Thanks.

EDIT: Upon further testing, it appears the issue might not be the autofocus, but mainly that just when the first letter typed is an R, it bugs out.

  • 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-25T15:16:08+00:00Added an answer on May 25, 2026 at 3:16 pm

    your selector with “not” was not correct.

    <script type="text/javascript">
    
    $(document).ready(function(){
        $('body').keydown(function(event) {
            if(event.keyCode==82) {
                $(document).trigger(location.href = '/?random')
            }
        });
        $('input, textarea').keydown(function(){
            event.stopPropagation();
        });
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When writing a Javascript a function that I had gotten help from earlier ,
Had finally gotten all the bugs out of this and now they said Oh,
Had a good search here but can't see anything that gets my mind in
Not sure where to start, but I had gotten the most recent version of
This question is expanding on another I had gotten help with via Stackoverflow (
I've gotten help from others on this, but their replies were a little bit
I saw a screencast where someone had gotten git st git ci to work.
Had to download Command Line Tools from Apple to get make to work, but
Had a good read through similar topics but I can't quite a) find one
Had a problem with the recursive conflictCheck() method. That seems fine now. I have

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.