Search code examples
firefoxfirefox-addonfirefox-addon-sdk

Firefox beforeSearch event


Is there an event in Firefox that is sent after the uses presses enter in the firefox search field? In Safari it is called SafariBeforeSearchEvent (beforeSearch).


Solution

  • I can't find any such event in FireFox nor have I heard of it before. However you might try simply capturing any events that might lead to the search bar in FireFox. Here's some simple JQuery that will tell you what event you just triggered. You can then set any conditions for Firefox as needed.

    F3 = event 114, Alt+F = event 70

    Hope this helps. Good Luck.

    <html>
    <head>
      <style type="text/css">
      </style>
    
      <script src="http://code.jquery.com/jquery-latest.js"></script>
    
      <script>
        $(document).ready(function () {
            //Catch F3
            $('body').on('keyup', function(e) {
                if(e.which==114) {
                  e.stopPropagation();
                  //START Call/insert my on before search routines here
                  alert(e.which);
                  //END -----------------------------------------------
                  return false;
                }
            });
    
            /*
            $('body').on('keyup', function(e) {
                alert(e.which);
            });
            */
    
        });
      </script>
    
    </head>
    <body>
    
    
    </body>
    </html>