开发者

right click menu using both key board and mouse

I am looking for some java script right click menu using both key board and m开发者_如何转开发ouse.

have any one seen a good plug in?


Using jQuery, to detect the right click you can do:

$('body').bind('mousedown', function(event) {
    if (event.which == 3) {
        // Create menu here
    }
});

To detect a certain key:

$('body').bind('keydown', function(event) { 
    if (event.which == //some key code, like 70) {
        // Create menu here
    }
});


Check out the oncontextmenu event, which is supported by every major browser except Opera. This will fire for the right-click and keyboard context menu if you want to display your own:

$("#myDiv").bind("contextmenu", function () {
    $("#menu").show();
    return false;
});

Note that Firefox users can expressly disable context menu overriding. For Opera, you'd have to bind to the click event and necessary key combinations (which may vary between operating systems).


have a look at these plugins...

right click plugin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜