Pregunta

Let I've the <a href="/link/"> tag. How can I the following handle: When the CTRL key is pressed we're left clicked to the <a href="/link/"> tag I want to run an appropriate function which I'll specified as handler of this event. How to do that? I want to do this with pure JS.

¿Fue útil?

Solución

<a href="#test" onclick="if(event.ctrlKey) alert('test');">test</a>

Otros consejos

I can also recommened the Jquery way.

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

May be seems a bit less simple, but I guess it gives you more options aswell.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top