From 9df998914d9b7d15afe8d98fad1c4e3750aad211 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Wed, 29 Jan 2014 18:38:42 +0100 Subject: [PATCH] Print shortcut: Ctrl + (Shift +) P only The previous version interfered with the full screen shortcut (Ctrl + Alt + P). The new version only intercepts Cmd/Ctrl + P (all browsers). And Ctrl + Shift + P in Chrome / Opera (Presto and Chromium), because these browsers also associate a Print operation with the shortcut. --- web/mozPrintCallback_polyfill.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/mozPrintCallback_polyfill.js b/web/mozPrintCallback_polyfill.js index c5eeb3548..a9416c143 100644 --- a/web/mozPrintCallback_polyfill.js +++ b/web/mozPrintCallback_polyfill.js @@ -98,7 +98,10 @@ var hasAttachEvent = !!document.attachEvent; window.addEventListener('keydown', function(event) { - if (event.keyCode === 80/*P*/ && (event.ctrlKey || event.metaKey)) { + // Intercept Cmd/Ctrl + P in all browsers. + // Also intercept Cmd/Ctrl + Shift + P in Chrome and Opera + if (event.keyCode === 80/*P*/ && (event.ctrlKey || event.metaKey) && + !event.altKey && (!event.shiftKey || window.chrome || window.opera)) { window.print(); if (hasAttachEvent) { // Only attachEvent can cancel Ctrl + P dialog in IE <=10