Permalink
Browse files

Added Ctrl-d as a shortcut to jump to search bar.

  • Loading branch information...
1 parent 6fa6ea0 commit 2379c18eb3c122ffb135ba9481b9d06acdb1d951 @vaporstun vaporstun committed Jul 15, 2010
@@ -11,9 +11,9 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
- <string>1.0</string>
+ <string>1.1</string>
<key>CFBundleVersion</key>
- <string>15</string>
+ <string>16</string>
<key>Chrome</key>
<dict>
<key>Bars</key>
@@ -50,7 +50,7 @@
</dict>
</dict>
<key>Description</key>
- <string>Adds DuckDuckGo Extension Bar and Right Click Context Menu Item</string>
+ <string>Adds DuckDuckGo Extension Bar and Right Click Context Menu Item. Ctrl-D to jump to search.</string>
<key>ExtensionInfoDictionaryVersion</key>
<string>1.0</string>
<key>Permissions</key>
@@ -62,5 +62,15 @@
<string>newWindow</string>
</array>
</dict>
+ <dict>
+ <key>DefaultValue</key>
+ <true/>
+ <key>Key</key>
+ <string>ddgShortcut</string>
+ <key>Title</key>
+ <string>Enable Ctrl-d shortcut for search</string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
</array>
</plist>
@@ -75,6 +75,17 @@
break;
}
}
+
+safari.application.addEventListener("message", captureMessageEvent, false);
+function captureMessageEvent(event) {
+ if (event.name == 'ddgFocus') {
+ ddgShortcut = safari.extension.settings.getItem("ddgShortcut");
+ if (ddgShortcut == true) {
+ document.getElementById('searchField').focus();
+ document.getElementById('searchField').select();
+ }
+ }
+}
</script>
</body>
</html>
@@ -5,4 +5,13 @@ function ddgHandler(ddgEvent) {
sel = window.parent.getSelection()+'';
sel = sel.replace(/^\s+|\s+$/g,"");
safari.self.tab.setContextMenuEventUserInfo(ddgEvent, sel);
-}
+}
+
+window.addEventListener('keydown', checkKeyDown, false);
+
+function checkKeyDown(e) {
+ if (e.which == 17) isCtrl=true;
+ if (e.which == 68 && isCtrl == true) {
+ safari.self.tab.dispatchMessage('ddgFocus');
+ }
+}
View
@@ -35,3 +35,20 @@ You will need to sign up for a Safari Extension Certificate if you want to fork
-Victor
vaporstun [at] gmail
+
+
+Copyright (C) 2010 Victor Quinn
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

0 comments on commit 2379c18

Please sign in to comment.