Search code examples
javascriptkeyboard-eventsfirefox-ossearch-form

Firefox OS: start searching on enter key press


I am new in Firefox OS. I have a search box.

After pressing the submit button it shows results perfectly. But I want to add keyboardevent like press enter button it will show result.


Solution

  • Try this:

          $("#SearchText").keydown(function (e) {
              var keyCode = e.keyCode || e.which;
    
              if (keyCode == 13) {
                //stop CR & do submit here instead
                document.forms["myform"].submit();
                return false;
              }
            });
    

    It intercepts every key press in the search text field and checks for Return.