Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4311
  • Last Modified:

Disabling CTRL+P, the print dialog, in IE8/9

Hi,

I would like to use CTRL+P as a hotkey in my webapplication. With jquery keydown function I'm able to catch the event and do what is supposed to be done. But although I'm catching the event and returning with the following code, the Printdialog is still shown by IE. Is there a way to disable the dialog?

Thanks,

Peter

$(document).keydown(function (e) {
	var keycode = e.which ? e.which : (e.keyCode ? e.keyCode : 0);
	if (!HotKeyHandler(keycode, e.ctrlKey, e.altKey, e.shiftKey)) {
		// Handled if false
		e.preventDefault();
		e.stopPropagation();
		return false;
	}
}

Open in new window


0
pivar
Asked:
pivar
  • 3
  • 2
  • 2
2 Solutions
 
Chris WongCommented:
0
 
pivarAuthor Commented:
I'm not sure I understand. How would this help me not showing the dialog when pressing Ctrl+P? As I understand it, it's used with window.print();. I don't want to print.
0
 
Chris WongCommented:
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
pivarAuthor Commented:
No sorry, I tried the openjs shortcut function, but no changes. I still get a printer dialog. But I noticed that the dialog doesn't show if you show an alert-dialog.
0
 
DanielleFavreauCommented:
I can't tell you how to do this but I can tell you that the newer versions of IE do not allow you to bypass the Print dialog (I and several major programmers tried at my day job to no avail for a custom SharePoint application and when we worked with Microsoft they said you can't do it without causing other issues).

With that said, you may want to reconsider doing this anyway. By doing so you're breaking the expected user experience.  

Instead of CTRL-P why not use CTRL-ALT-P or Windows button P?

By breaking the user experience you are setting your users up to feel stupid, which no one likes.  It is never recommended to go against common user experience (like having a search area at the top right of a site, having the logo at the top left or middle, letting the back button be the back button, etc.)
0
 
pivarAuthor Commented:
I got this issue becuse we're moving an old windowsclient to the web, and wanted to keep the old hotkeys. I've come to the same conclusion as you, thanks for the confirmation. I ended up using Ctrl+Shift instead of Ctrl.
0
 
DanielleFavreauCommented:
Glad you figured out a solution.  IE doesn't make things easy for developers ... that would be much too nice of Microsoft ;)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now