diff --git a/app/content/webviewPreload.js b/app/content/webviewPreload.js index e253a104aed..69bd5a69397 100644 --- a/app/content/webviewPreload.js +++ b/app/content/webviewPreload.js @@ -5,6 +5,7 @@ var webFrame = require('electron').webFrame var ipc = require('electron').ipcRenderer var messages = require('../../js/constants/messages') +var KeyCodes = require('../../js/constants/keyCodes') var browserZoomLevel = 0 var browserMaxZoom = 9 @@ -179,3 +180,12 @@ document.addEventListener('contextmenu', (e) => { ipc.send(messages.CONTEXT_MENU_OPENED, e.target.nodeName) e.preventDefault() }, false) + +document.onkeydown = (e) => { + switch (e.keyCode) { + case KeyCodes.ESC: + e.preventDefault() + ipc.send(messages.STOP_LOAD) + break + } +} diff --git a/app/index.js b/app/index.js index a761e6a5dca..b8932638598 100644 --- a/app/index.js +++ b/app/index.js @@ -34,6 +34,9 @@ app.on('ready', function () { ipcMain.on(messages.CONTEXT_MENU_OPENED, (e, nodeName) => { BrowserWindow.getFocusedWindow().webContents.send(messages.CONTEXT_MENU_OPENED, nodeName) }) + ipcMain.on(messages.STOP_LOAD, () => { + BrowserWindow.getFocusedWindow().webContents.send(messages.STOP_LOAD) + }) Menu.init() diff --git a/app/localShortcuts.js b/app/localShortcuts.js index 06a70885c73..576d5907e23 100644 --- a/app/localShortcuts.js +++ b/app/localShortcuts.js @@ -18,8 +18,7 @@ module.exports.register = (win) => { ['CmdOrCtrl+Shift+]', messages.SHORTCUT_NEXT_TAB], ['CmdOrCtrl+Shift+[', messages.SHORTCUT_PREV_TAB], ['CmdOrCtrl+9', messages.SHORTCUT_SET_ACTIVE_FRAME_TO_LAST], - ['CmdOrCtrl+Shift+T', messages.SHORTCUT_UNDO_CLOSED_FRAME], - ['Escape', messages.SHORTCUT_ACTIVE_FRAME_STOP] + ['CmdOrCtrl+Shift+T', messages.SHORTCUT_UNDO_CLOSED_FRAME] ] // Tab ordering shortcuts diff --git a/js/components/findbar.js b/js/components/findbar.js index 6c03cbfb9f1..77227ad10b3 100644 --- a/js/components/findbar.js +++ b/js/components/findbar.js @@ -72,16 +72,15 @@ export default class FindBar extends ImmutableComponent { onKeyDown (e) { switch (e.keyCode) { case keyCodes.ESC: - // ESC is handled by a local shortcut, so use shift+ESC - if (e.shiftKey) { - this.props.onHide() - } + e.preventDefault() + this.props.onHide() break case keyCodes.ENTER: + e.preventDefault() if (e.shiftKey) { this.onFindPrev() } else { - this.onFind() + this.onFindNext() } break } diff --git a/js/components/main.js b/js/components/main.js index 7699a2198bf..c77d7a733eb 100644 --- a/js/components/main.js +++ b/js/components/main.js @@ -35,6 +35,9 @@ class Main extends ImmutableComponent { }) } + ipc.on(messages.STOP_LOAD, () => { + electron.remote.getCurrentWebContents().send(messages.SHORTCUT_ACTIVE_FRAME_STOP) + }) ipc.on(messages.CONTEXT_MENU_OPENED, (e, nodeName) => { console.log('got context menu open', nodeName) contextMenus.onMainContextMenu(nodeName) diff --git a/js/components/urlBar.js b/js/components/urlBar.js index e9f411442c3..4a745b7ae16 100644 --- a/js/components/urlBar.js +++ b/js/components/urlBar.js @@ -10,6 +10,7 @@ const WindowActions = require('../actions/windowActions') const KeyCodes = require('../constants/keyCodes') const cx = require('../lib/classSet.js') const ipc = global.require('electron').ipcRenderer +const remote = global.require('electron').remote const UrlBarSuggestions = require('./urlBarSuggestions.js') const messages = require('../constants/messages') @@ -103,7 +104,10 @@ class UrlBar extends ImmutableComponent { e.preventDefault() } break - // escape is handled by ipc shortcut-active-frame-stop event + case KeyCodes.ESC: + e.preventDefault() + remote.getCurrentWebContents().send(messages.SHORTCUT_ACTIVE_FRAME_STOP) + break default: } } diff --git a/js/constants/messages.js b/js/constants/messages.js index 2d5c2a1b9a9..e5a5b8eeb92 100644 --- a/js/constants/messages.js +++ b/js/constants/messages.js @@ -44,7 +44,8 @@ const messages = { SET_AD_DIV_CANDIDATES: _, /** @arg {Array} adDivCandidates, @arg {string} placeholderUrl */ CONTEXT_MENU_OPENED: _, /** @arg {string} nodeName of node being clicked */ APP_STATE_CHANGE: _, - APP_ACTION: _ + APP_ACTION: _, + STOP_LOAD: _ } module.exports = mapValuesByKeys(messages)