From 83ad636cf7c15b69a17ce8395145e49da4488bc5 Mon Sep 17 00:00:00 2001 From: thmsbfft Date: Sun, 15 Jan 2017 17:58:53 -0800 Subject: [PATCH] Add lucky search to omnibox --- src/js/main/Window.js | 2 +- src/js/renderer/Omnibox.js | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/js/main/Window.js b/src/js/main/Window.js index 208e23e..7abc7da 100644 --- a/src/js/main/Window.js +++ b/src/js/main/Window.js @@ -59,7 +59,7 @@ function Window(parameters) { this.browser.loadURL('file://' + __dirname + '/src/html/index.html' + '#' + this.id); // @if NODE_ENV='development' - this.browser.webContents.openDevTools(); + // this.browser.webContents.openDevTools(); // @endif } diff --git a/src/js/renderer/Omnibox.js b/src/js/renderer/Omnibox.js index c45ad6c..77a92dd 100644 --- a/src/js/renderer/Omnibox.js +++ b/src/js/renderer/Omnibox.js @@ -111,17 +111,30 @@ Omnibox.prototype.onInputKeyDown = function(e) { Omnibox.prototype.onInputKeyUp = function(e) { - if(e.keyCode == 9) { - // Tab + if(e.ctrlKey && e.keyCode == 13 && this.searchDictionary.direct) { + + // Ctrl + Enter + var raw = this.input.value; + var url = this.searchDictionary.direct.replace('{query}', raw); + this.submitCallback(url); + e.preventDefault(); + return; + } + if(e.keyCode == 13) { + // Enter removeClass(this.input, 'highlight'); this.submit(); e.preventDefault(); + } + if(e.key == "Escape") { - if(!Browser.isFirstLoad) this.hide() + + if(!Browser.isFirstLoad) this.hide(); + } var customSearch = this.getCustomSearch();