2019-10-09
How to disable CTRL + mouse Left Click?
stackoverflow
Question

I want to disable Ctrl + mouse Left Click event on links. I tried with keypress event but it doesn't work:

$('a').keypress(function (e){  
    if (e.ctrlKey && e.keyCode === 13) {
        return false;
    }
});

jsFiddle

Answer
1

The code that you have disables Ctrl+enter. To disable Ctrl+click, you would use the click event:

$('a').click(function (e){  
    if (e.ctrlKey) {
        return false;
    }
});

Demo: http://jsfiddle.net/WYxUE/45/

Note: Actually disabling ctrl+click would normally not be a good idea, and not very effective. In windows it's used to open the page in a new tab, and if that is disabled you can just use shift+click to open it in a new window instead, or right click and choose Open link in new tab.

How to disable CTRL + mouse Left Click?
See more ...