Mobile Submission Form Safari

I have basic formc search inputand a submit buttoninside. When focus occurs in input, the keyboard is displayed as expected. When I click button, a form submit event occurs in which I call event.preventDefault()and instead make an ajax call. However, when I press the search button on the keyboard, the keyboard just hides and the send event does not occur.

Why is the form not submitted when I click on the keyboard? How can I fire this event using the keyboard search button?

Thank.

+5
source share
1 answer

keycode 13.

, keypress , e.which === 13

$('input').on('keypress', function ( e ) {
    if ( e.which !== 13 ) {
        return;
    }

    // ajax code
}
+5

All Articles