Unfortunately, event.metaKey does not evaluate to true on Windows when the ctrl key is held on click.
Fortunately, event.ctrlKey does evaluate to true in these situations. Also, you may want to consider shift + clicks in your event handler.
Thus, your cross platform jquery flavored javascript code would look something like:
$('ul#tabs li a').on('click', function(e) {
var link = $(this).attr('href');
// Check "open in new window/tab" key modifiers
if (e.shiftKey || e.ctrlKey || e.metaKey) {
window.open(link, '_blank');
} else {
$('#content').fadeOut('fast',function(){
window.location = link;
});
}
}
});
Answer from Leighton Wallace on Stack OverflowIs there a way to make <ctrl + cmd + click on desktop> the normal behavior when I click on desktop?
Can you Cmd Click and Cmd Ctrl Click A Button?
keyboard - jQuery: detecting cmd+click / control+click - Stack Overflow
How to configure Command+Click to be Ctrl-Click on Windows? | Parallels Forums
What is Ctrl+Click?
How does Ctrl+Click work?
What are some common uses of Ctrl+Click?
I'd like to mimic the Windows behavior of clicking on "glance desktop" and minimizing/hiding all windows when doing so. I know I can achieve this by holding ctrl + cmd + clicking on the desktop, but is there a way to make the *single* action of clicking on the desktop to mimic the aforementioned behavior?
Hope I made myself clear. Thanks in advance
Unfortunately, event.metaKey does not evaluate to true on Windows when the ctrl key is held on click.
Fortunately, event.ctrlKey does evaluate to true in these situations. Also, you may want to consider shift + clicks in your event handler.
Thus, your cross platform jquery flavored javascript code would look something like:
$('ul#tabs li a').on('click', function(e) {
var link = $(this).attr('href');
// Check "open in new window/tab" key modifiers
if (e.shiftKey || e.ctrlKey || e.metaKey) {
window.open(link, '_blank');
} else {
$('#content').fadeOut('fast',function(){
window.location = link;
});
}
}
});
In your click function, does e.metaKey evaluate to true? If so, there you are.
In HTML files the command is "Open Link" (editor.action.openLink). This command does not have, by default, associated a key combination. You can assign one by using the Preferences -> Keyboard Shortcuts command from the menu (click on the gear on the bottom of the primary side bar).
In other contexts (source code in various programming languages), the combination Ctrl+click (or Cmd+click on macOS) when the cursor is on an identifier (constant name, variable name, function name, class name, etc.) is equivalent with command "Go to Definition" (editor.action.revealDefinition). This command has, by default, associated the key F12.
Do Command/Control P > keybindings.json and insert:
[
...,
{
"key": "ctrl+f12",
"command": "editor.action.openLink"
}
]
to set Ctrl F12 to open the link under the cursor.
First and foremost, please note that in VS Code for macOS, the familiar Ctrl + click from Windows / Linux operating systems has been replaced with ⌘ + click (i.e.: "command + click"). Try that first before proceeding any further as that shortcut should work out of the box without any special modifications.
However, if the above still doesn't work for you then try fixing the problem by editing your settings.json file. To do that, press F1, type settings json, then click Open Settings (JSON), and then do one of the following:
To use ⌘ + click as your "Go to definition" shortcut, ensure the following line exists in your JSON settings:
"editor.multiCursorModifier": "alt",
What this does is it explicitly sets VS Code's "add another cursor" shortcut to option + click (try it out for yourself!), thus freeing up ⌘ + click to be used for the "Go to definition" operation.
Conversely, to use option + click as your "Go to definition" shortcut instead, add:
"editor.multiCursorModifier": "ctrlCmd",
Note: the above line will actually set the "add another cursor" shortcut to ⌘ + click (not Ctrl + ⌘ + click, as implied by the JSON value).
Settings > User > multiCursorModifier must be set to alt (default), so the ctrl/cmd will be available to go to definition.
Documentation:
The modifier to be used to add multiple cursors with the mouse. The Go To Definition and Open Link mouse gestures will adapt such that they do not conflict with the multicursor modifier.
EDIT: Fixed in macOS 12.5 🎉
My brand new 14-inch MBP M1 Max is freaking awesome, except that tapping on the trackpad while pressing the Ctrl and Cmd key almost never works... until I tap a third time.
Quick demo video
How to reproduce:
-
System Preferences → Trackpad → Enable "Tap to click."
-
Move the cursor over the desktop, hold the Ctrl key, tap the trackpad (don't click!).
-
Right-click menu does not appear.
-
Do NOT move the cursor, keep pressing the Ctrl key, and tap twice more. Time interval between taps doesn't matter.
-
Right-click menu appears.
-
If keeping the Ctrl key pressed, subsequent taps always show the right-click menu.
-
If releasing and pressing the Ctrl key again, it takes again 3 taps until the right-click menu shows up.
This is seriously handicapping when displaying the right-click menu with Ctrl+tap (even though the 2-finger tap works) but ever more when doing a Cmd+tap, to open a link in a background tab in browsers, or to show that super convenient menu in Xcode.
Issue also happens on safe mode, and even after a clean install of macOS 12.0.1. Some people reported it on their own MBPs or demo ones at Apple Stores, and only on 14-inch models. Some people also had it on a 13-inch M1 MBPs. I also reproduced a couple of times on my own one, but it happens way less often.
Interestingly, "clicking" instead of tapping does work reliably. Also, tapping once, moving the cursor, then tapping again works.
If anyone with a 14-inch MBP could give it a try and chime in, that would be great. This looks like some software issue, and hopefully Apple will quickly notice and fix it. If anyone has installed the macOS 12.1 beta, feedback are also welcome. Thanks a lot!