Another way would be to use the ctrlKey property of the Click event:

$('#element').click(function(e)
        {
                if (e.ctrlKey)
                {
                        do_something();
                }
        });

jQuery also normalizes this into the metaKey attribute which detects the CMD
key on a Mac:

$('#element').click(function(e)
        {
                if (e.metaKey)
                {
                        do_something();
                }
        });
-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of andrea varnier
Sent: Monday, February 04, 2008 6:35 AM
To: jQuery (English)
Subject: [jQuery] Re: Detecting ctrl+click on an element


On 4 Feb, 14:38, Giovanni Battista Lenoci <[EMAIL PROTECTED]> wrote:
> The subject says it all...
>
> How I can detect a crtl+click on an element?

try this, supposing #target is yout target

var clickFn = function(){
        alert("ctrl + click");
        $(this).unbind('click', clickFn);
}

$(document)
        .keydown(function(event){
                if (event.keyCode == 17){
                        $("#target").click(clickFn);
                }
        })
        .keyup(function(event){
                if (event.keyCode == 17){
                        $("#target").unbind('click', clickFn);
                }
        });

Reply via email to