agungprasetyosakti / js-hotkeys

Automatically exported from code.google.com/p/js-hotkeys
0 stars 0 forks source link

Failed to prevent Firefox quick search bar from appearing when pressing '/' #40

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. First problem is I can't find a way to bind '/'. I solve it by adding an
entry in specialKeys: {
         ....
         120:'f9', 121:'f10', 122:'f11', 123:'f12',
         191:'slash'            // by vole
}
Then I can bind it by "$(document).bind('keydown', 'slash', somehandler);"
2. In Firefox, when pressed '/', the quick search bar will appear. Even
'somehandler' return false, the bar will still appear.
3. Even I add some more code at hotkeys.handler, it seems still not work
for me. Before return result, I added:                  
                    if (!result) {
                        // by vole
                        var patchE = event.originalEvent;
                        if (patchE.stopPropagation) patchE.stopPropagation( );  // DOM
model
                        if (patchE.cancelBubble) patchE.cancelBubble = true;          
       // IE model
                        if (patchE.preventDefault) patchE.preventDefault( );    // DOM
                        if (patchE.returnValue) patchE.returnValue = false;           
      // IE
                    }
                    return result;

I tried out the above code outside jQuery & jquery.hotkeys, it works for me.

What is the expected output? What do you see instead?
I want to prevent the Firefox quick search bar from appearing.
But it appears anyway.

What version of the product are you using? On what operating system?
jquery.hotkeys-0.7.8.js
jquery-1.2.6.js
Windows XP SP2
Firefox 3.0.5

Please provide any additional information below.

Original issue reported on code.google.com by volezh...@gmail.com on 10 Jan 2009 at 9:38

GoogleCodeExporter commented 8 years ago
It works over here ;-)
I made you a special sample and special commit

plug-in code: 
http://github.com/tzuryby/jquery.hotkeys/tree/master/jquery.hotkeys.js
demo code: 
http://github.com/tzuryby/jquery.hotkeys/tree/master/test-static-04.html

Hope that will work for you. 
Let me know if not.

Thanks for using jquery.hotkeys

Original comment by Afro.Sys...@gmail.com on 11 Jan 2009 at 12:35

GoogleCodeExporter commented 8 years ago
Thanks for your help. But the demo doesn't work for me.... Here is the 
screenshot.
If the quick search bar appear, the focus will move to it, which will affect the
usability. Maybe that's because my firefox is Chinese version, not standard 
English
version? I'm not sure...

Original comment by volezh...@gmail.com on 12 Jan 2009 at 3:01

Attachments:

GoogleCodeExporter commented 8 years ago
At first, I checked it on my laptop which runs Linux and it works fine.
After seeing your comment, I launched a virtual instance of windows and got the 
same
behaviour you described. So I guess it has to do with Firefox on windows (and 
not
necessaryly the Chinese flavour).

Anyway, this is beyond the scope if this plug-in.

Original comment by Afro.Sys...@gmail.com on 12 Jan 2009 at 7:18

GoogleCodeExporter commented 8 years ago
I see. Thanks for your consideration. But I solved the problem by using native 
event
handling. So I suspect it has to do with jQuery's event processing (not 
necessiraly
your js-keys, because you are using jQuery's event, too.)
Here is my final solution. It work on my firefox on windows. So I guess it 
should
work on linux, too. It's just for your reference. Thank you anyway.

Original comment by volezh...@gmail.com on 13 Jan 2009 at 12:39

Attachments:

GoogleCodeExporter commented 8 years ago
I will use the attached as a reference when revisiting this issue sometimes in 
the
near future.

Original comment by Afro.Sys...@gmail.com on 13 Jan 2009 at 1:12

GoogleCodeExporter commented 8 years ago
Hi, I overlooked at this issue and come up with the following:
Which works fine and prevents the default and stop propagations for you

note: I check this with jQuery 1.3.1 (latest)

jQuery(document).bind('keydown', '/', function (evt){
                    alert("Hello Slash"); 
                    evt.stopPropagation( );  
                    evt.preventDefault( );
                    return false;
                });

Original comment by Afro.Sys...@gmail.com on 4 Feb 2009 at 2:19

GoogleCodeExporter commented 8 years ago
I will try it. Thank you!

Original comment by volezh...@gmail.com on 5 Feb 2009 at 2:35

GoogleCodeExporter commented 8 years ago
jQuery(document).bind('keydown', '/', function (evt){
                    alert("Hello Slash"); 
                    evt.stopPropagation( );  
                    evt.preventDefault( );
                    return false;
                });

does not work on jquery 1.3.2 and js-hotkeys 0.7.8 packed, no response across 
any
browsers.  Changing the slash to a letter runs correctly.

Original comment by chris.sg...@gmail.com on 24 Feb 2009 at 8:16

GoogleCodeExporter commented 8 years ago
check it with the github's version
http://github.com/tzuryby/jquery.hotkeys/tree/master

it works fine on my linux machine

Original comment by Afro.Sys...@gmail.com on 24 Feb 2009 at 8:21