• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4574
  • 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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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