From ba59d7f8b4d119144bae60144a9447f4f6385dc4 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Thu, 7 Jan 2010 23:59:58 -0800 Subject: Use the CTRL key instead of the meta key to open links in new windows on Linux & Windows. Fixes #46. --- linkHints.js | 10 ++++++---- 1 file 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); -- cgit v1.2.3