From fd7d41a02a08d62e8eeee08d1d36daf44dec8b1b Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Thu, 17 Nov 2016 16:50:56 -0500 Subject: [PATCH] Desktop client: Support Ctrl+F/Cmd+F This is very basic support just so people have a find command at all. --- js/client.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/client.js b/js/client.js index 814538796..9203887aa 100644 --- a/js/client.js +++ b/js/client.js @@ -514,7 +514,23 @@ // keypress happened in an empty textarea or a button var safeLocation = ((tagName === 'TEXTAREA' && !el.value.length) || tagName === 'BUTTON'); + var isMac = (navigator.userAgent.indexOf("Mac") !== -1); + if (e.keyCode === 70 && window.nodewebkit && (isMac ? e.metaKey : e.ctrlKey)) { + e.preventDefault(); + e.stopImmediatePropagation(); + var query = window.getSelection().toString(); + query = window.prompt("find?", query); + if (query) window.find(query); + return; + } + if (e.keyCode === 71 && window.nodewebkit && (isMac ? e.metaKey : e.ctrlKey)) { + e.preventDefault(); + e.stopImmediatePropagation(); + var query = window.getSelection().toString(); + if (query) window.find(query); + return; + } if (app.curSideRoom && $(e.target).closest(app.curSideRoom.$el).length) { // keypress happened in sideroom if (e.shiftKey && e.keyCode === 37 && safeLocation) {