diff --git a/apps/documenteditor/embed/js/SearchBar.js b/apps/documenteditor/embed/js/SearchBar.js index 4c7f86f6a1..c5e08ef72c 100644 --- a/apps/documenteditor/embed/js/SearchBar.js +++ b/apps/documenteditor/embed/js/SearchBar.js @@ -51,7 +51,41 @@ searchText: '' }, _lastInputChange, - _searchTimer; + _searchTimer, + _mods = { + ctrl: false, + f: false, + other: false + }; + + var init = function (config) { + appConfig = config; + + $(document.body).on('keydown', function (event) { + if (event.keyCode === 27 && $searchBar && $searchBar.is(':visible')) { + highlightResults(false); + $searchBar.hide(); + return; + } + if (event.keyCode === 70) { + _mods.f = true; + } + if (event.ctrlKey || event.metaKey) { + _mods.ctrl = true; + } + if (event.altKey || event.shiftKey) { + _mods.other = true; + } + if (_mods.f && _mods.ctrl && !_mods.other) { + event.preventDefault() + onShow(); + } + }).on('keyup', function () { + for (var key in _mods) { + _mods[key] = false; + } + }); + }; var setApi = function (appApi) { api = appApi; @@ -165,7 +199,7 @@ }; return { - init: function(config) { appConfig = config; }, + init: init, setApi: setApi, show: onShow }; diff --git a/apps/spreadsheeteditor/embed/js/SearchBar.js b/apps/spreadsheeteditor/embed/js/SearchBar.js index 5d9a77a097..d1e6579f38 100644 --- a/apps/spreadsheeteditor/embed/js/SearchBar.js +++ b/apps/spreadsheeteditor/embed/js/SearchBar.js @@ -51,7 +51,41 @@ searchText: '' }, _lastInputChange, - _searchTimer; + _searchTimer, + _mods = { + ctrl: false, + f: false, + other: false + }; + + var init = function (config) { + appConfig = config; + + $(document.body).on('keydown', function (event) { + if (event.keyCode === 27 && $searchBar && $searchBar.is(':visible')) { + highlightResults(false); + $searchBar.hide(); + return; + } + if (event.keyCode === 70) { + _mods.f = true; + } + if (event.ctrlKey || event.metaKey) { + _mods.ctrl = true; + } + if (event.altKey || event.shiftKey) { + _mods.other = true; + } + if (_mods.f && _mods.ctrl && !_mods.other) { + event.preventDefault() + onShow(); + } + }).on('keyup', function () { + for (var key in _mods) { + _mods[key] = false; + } + }); + }; var setApi = function (appApi) { api = appApi; @@ -171,7 +205,7 @@ }; return { - init: function(config) { appConfig = config; }, + init: init, setApi: setApi, show: onShow };