diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 8b048a70a..de976a171 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -424,6 +424,24 @@ define([ logoutHandlers.push(h); }; + var shortcuts = []; + funcs.addShortcuts = function (w) { + w = w || window; + if (shortcuts.indexOf(w) !== -1) { return; } + shortcuts.push(w); + $(w).keydown(function (e) { + // Ctrl || Meta (mac) + if (e.ctrlKey || (navigator.platform === "MacIntel" && e.metaKey)) { + // Ctrl+E: New pad modal + if (e.which === 69) { + e.preventDefault(); + return void funcs.createNewPadModal(); + } + // Ctrl+S: prevent default (save) + if (e.which === 83) { return void e.preventDefault(); } + } + }); + }; Object.freeze(funcs); return { create: function (cb) { @@ -500,6 +518,8 @@ define([ }); ctx.metadataMgr.onReady(waitFor()); + + funcs.addShortcuts(); }).nThen(function () { try { var feedback = ctx.metadataMgr.getPrivateData().feedbackAllowed; diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index e5e1ce00d..644cecf7a 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -863,6 +863,7 @@ Messenger, MessengerUI, Messages) { }); $(window).keydown(function (e) { if (e.which === 69 && (e.ctrlKey || (navigator.platform === "MacIntel" && e.metaKey))) { + e.preventDefault(); Common.createNewPadModal(); } }); diff --git a/www/pad/inner.js b/www/pad/inner.js index cd382b5b6..387d27311 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -428,6 +428,8 @@ define([ var ifrWindow = $html.find('iframe')[0].contentWindow; + framework._.sfCommon.addShortcuts(ifrWindow); + var documentBody = ifrWindow.document.body; var observer = new MutationObserver(function (muts) {