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.
This commit is contained in:
Rob Wu 2014-01-29 18:38:42 +01:00
parent c5a804c43a
commit 9df998914d

View File

@ -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