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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:06:16+00:00 2026-05-27T11:06:16+00:00

I am currently working on a menu in jQuery, which has keyboard shortcuts for

  • 0

I am currently working on a menu in jQuery, which has keyboard shortcuts for the menu items, as well as access keys.

I pass data to build the menu using an object literal, which storesd the function that is to be bound to the menu item, something like this:

var my_menu = [
    { 
        label     : 'File',
        accessKey : 'F',
        func      : function() { alert('File shown'); } 
    }
];

I am binding the func function to the menu item (an <li> element) using jQuery’s click() function, something like:

this_li.click(function() { this_click_func.call() });

I then add keyboard support by listening for keydown() on the document. If the combination of keys match the accessKey, I simply use the click() method in jQuery to fire the function, even though in reality, they haven’t clicked the item.

This works fine, but I wanted opinion on this method. Would it be better practice to run the function when the combination of keys match as well, or is it sufficient to simply replicate a click using click()?

Any comments gratefully received.

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

    You should not trigger the click() handler, as other components/ plugins may also have subscribed to the click() event.

    In your keydown() handler you should again call this_click_func.call().

    Furthermore, what you’ve got is Object Literal Notation, not JSON.

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

Sidebar

Related Questions

I am working on a website that has a menu which behaves correctly on
We are currently working on an instrumentation test suite which runs on our build
**I currently have this jQuery drop menu working fine but I'm wanting the parent
I am currently working on a JS menu for a web app. It consists
I am working to build a menu in coldfusion based on xml. current working
I'm currently working on a project in which at one point, the user may
I'm working on a case resolution system, and am currently using a jquery colorbox
I am currently working on a task to make a pop-up menu, and here
Iam currently working on a iPad project where i build my code on top
I am currently working on a very large legacy MFC MDI application. It has

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.