aboutsummaryrefslogtreecommitdiffstats
path: root/linkHints.js
diff options
context:
space:
mode:
authorPhil Crosby2010-01-07 23:59:58 -0800
committerPhil Crosby2010-01-07 23:59:58 -0800
commitba59d7f8b4d119144bae60144a9447f4f6385dc4 (patch)
treec4a109b3678c04d70e18e5ed8a5ebcf68de7e0b6 /linkHints.js
parent293418c6d5a418d56a1141cd30d03cb1fe2713a8 (diff)
downloadvimium-ba59d7f8b4d119144bae60144a9447f4f6385dc4.tar.bz2
Use the CTRL key instead of the meta key to open links in new windows on Linux & Windows. Fixes #46.
Diffstat (limited to 'linkHints.js')
-rw-r--r--linkHints.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/linkHints.js b/linkHints.js
index 047cbcae..0d16bab1 100644
--- a/linkHints.js
+++ b/linkHints.js
@@ -232,10 +232,12 @@ function numberToHintString(number, numHintDigits) {
function simulateClick(link) {
var event = document.createEvent("MouseEvents");
- // When "clicking" on a link, dispatch the event with the meta key on Mac to open it in a new tab.
- // TODO(philc): We should dispatch this event with CTRL down on Windows and Linux.
- event.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false,
- shouldOpenLinkHintInNewTab, 0, null);
+ // When "clicking" on a link, dispatch the event with the appropriate meta key (CMD on Mac, CTRL on windows)
+ // to open it in a new tab if necessary.
+ var metaKey = (platform == "Mac" && shouldOpenLinkHintInNewTab);
+ var ctrlKey = (platform != "Mac" && shouldOpenLinkHintInNewTab);
+ event.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, ctrlKey, false, false, metaKey, 0, null);
+
// Debugging note: Firefox will not execute the link's default action if we dispatch this click event,
// but Webkit will. Dispatching a click on an input box does not seem to focus it; we do that separately
link.dispatchEvent(event);