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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:45:51+00:00 2026-06-07T16:45:51+00:00

How do I differentiate between right click using mouse and context menu key press

  • 0

How do I differentiate between right click using mouse and context menu key press on a physical keyboard?

Using this code I tried printing event in console

$('#'+inputId).bind('contextmenu', function(e) {
    console.log(e);
});

I grabbed some output for the above code-

For right click using the mouse it is-

  1. button: 2
  2. originalEvent: MouseEvent
  3. type: “contextmenu”
  4. which: 3

For context menu key press on the keyboard it is-

  1. button: 2
  2. originalEvent: MouseEvent
  3. type: “contextmenu”
  4. which: 3

I want to perform some action only when ‘context menu key’ is pressed on the physical keyboard. How do I achieve that?

  • 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-07T16:45:53+00:00Added an answer on June 7, 2026 at 4:45 pm

    Hiya there This will help you to capture the difference: Working Demo http://jsfiddle.net/pPnME/1/

    I have tested this on Alienware – Chrome, when you will right click you will see the right click alert other wise on keyboard you will see keyborad alert.

    Please note: you can identify the click based on which property: http://api.jquery.com/event.which/

    For key or mouse events, this property indicates the specific key or
    button that was pressed.

    Hope this fits the cause. :)

    Also note there are few plugins available to get the shortcut but I would recommend stick to the basic and use the demo I have given if its only to capture both event separately rest demo is all your to play 🙂

    code

    /*
      1 = Left   Mousebutton
      2 = Centre Mousebutton
      3 = Right  Mousebutton
    */
    $('input').mousedown(function(e) {
        if (e.which === 3) {
            alert('rightclick'); /* Right Mousebutton was clicked! */
        }
    });
    $('input').bind('contextmenu', function(e) {
        alert('keyboard yeah');
        //console.log(e);
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I differentiate between elements inside a table that is populated using a
What I need is to clearly differentiate between the attachments (this is an approval,
I am using Google analytics and wish to differentiate between two different cases on
Though this works to return the right results, SELECT r.KeyColumn as '@Key', t1.Key1 as
How to differentiate between swiping from left-to-right & right-to-left in a UITableView cell. Anyone
I am struggling to differentiate between all of the different couch* technologies that are
How can we differentiate between var foo; and var foo=undefined; ? typeof foo will
I'm looking to differentiate between Core Solo/Duo and Core 2 Duo processors for 64-bit
How can I differentiate between two local branches in git ? How can I
I have to differentiate between an incoming request from an Iphone App and an

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.