PDA

View Full Version : Restricting Hot Keys from browser



vinothsencha
12 Aug 2013, 9:14 AM
I have implemented the following code to restrict browser's default behavior:

Ext.create('Ext.util.KeyMap', component.getEl(), {
alt: true,
key: "f",
scope: component,
fn: function(keyCode, e)
{
e.stopEvent();
// Our own functionality
this.onOpenSelectedClick();
}
});

The above code is working correctly in Chrome and Firefox.
(Only our functionality executes)

But it is not working in IE (v 9.0) and Safari (v 5.0.3)
(Our functionality executes. Also, browser 'File' Menu opens)

Can you please tell us how to restrict the default behavior in IE and Safari also?

Also, is there a way to restrict commonly in all browsers?

Gary Schlosberg
12 Aug 2013, 3:10 PM
Well, if e.stopEvent() doesn't work for you, you may be out of luck. The answer to this (http://www.sencha.com/forum/showthread.php?259019) post indicates that not all browsers allow all hotkey overrides. It also has a suggestion which might be helpful to you, involving adding a keydown listener.

vinothsencha
12 Aug 2013, 11:06 PM
Thanks Gary..

Can you please give me a sample code to achieve this by using keydown listener?

vinothsencha
19 Aug 2013, 12:00 AM
Hi Gary,

Can you please provide a sample code snippet by using key down listener to restrict the default bahavior of the browser?

Thanks in advance..

Gary Schlosberg
22 Aug 2013, 3:43 PM
I tried to throw this together, but it's not working. As I mentioned, you may be out of luck on this one. Some hotkeys can't be overridden.

vinothsencha
23 Aug 2013, 4:25 AM
Thanks gary...