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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:30:03+00:00 2026-06-02T08:30:03+00:00

When focus is on a button in a JQuery dialog, the space bar does

  • 0

When focus is on a button in a JQuery dialog, the space bar does two things: it selects the button and it scrolls the window. People who are familiar with space bar as a tool for selecting buttons will expect the first but find the second jarring and inappropriate.

So the question: how do I prevent the page from scrolling? I had thought that it was just a matter of returning false from the button handler but that does not appear to be true.

  • 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-02T08:30:05+00:00Added an answer on June 2, 2026 at 8:30 am

    I’ve tried the solution suggested here and elsewhere and none of them worked for me. What finally worked was a document-wide keydown handler like this:

    $(document).keydown(function (e) {
        var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
        if ((key == 32) && (e.target.className != null) && (e.target.className.indexOf("ui-button") != -1))
           e.preventDefault();
     });
    

    The key == 32 is obviously a check for the space bar. The className is a check for whether the UI (User Interface) element in question is a JQuery button. Without the button check, the space bar is disabled everywhere.

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

Sidebar

Related Questions

Does anyone know how can I default/focus a button by using jquery? If I
eHello everyone,the following is my code to display a jquery dialog window with a
I've got a jQuery dialog box with a button to close it. The button
When a jQuery UI dialog opens, it selects one of the buttons and highlights
$('.my-button').click(function() { $(.my-textbox).focus() }); Before Jquery 1.4 this used to be the way to
I am trying to bring focus to window using jquery. The window is popup
Please help to replace these jQuery functions with Prototype ones: $(button,input,label,select,textarea).bind('mouseover mouseout', function(){$(this).toggleClass('hover')}); $(button,input,select,textarea).bind('focus
How can I remove focus from submit button? I don't know why it is
Hi I am trying to set focus to a button when it is tabbed
I have a page in which i can successfully use the jquery focus function

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.