jquery - How to differentiate between 'right click using mouse' AND 'context menu key press on physical keyboard' -
How can I distinguish between right click by pressing the mouse on the physical keyboard and the context menu key?
Using this code I tried printing in the console
$ ('#' + inputId) .bind ('contextmenu', function (e) {console} .log (e);}); I caught some output for the above code -
To right click using the mouse -
Just want to do the work when the 'contextmenu key' is pressed on the physical keyboard, how do I get it? Thanks in advance!
Here it will help you find differences: task demo < / P>
I tested it on Alienware - Chrome, when you right click, you will right-click on the keyboard according to the keyboard and you will see a keybread alert.
Please note: You can identify the click based on which property:
For key or mouse events, this property is specific The key or button indicates that was pressed.
Hopefully this reason fits. :)
Also note that some plugins are available to get the shortcut, but I recommend sticking the original and the demo I used to use Only if both events are played separately to the rest of the demo.
Code
/ * 1 = left mouse button 2 = center mouse button 3 = Right mouse button * / $ ('Input'). Musudown (function (e) {if (e.which === 3) {Warning ('rightclick'); / * Right mouse button was clicked!}}}); $ ('Input'). Bind ('context menu', function (e) {warning ('keyboard yes'); //console.log (a);});
Comments
Post a Comment