A
A
Alexander Petrov2015-12-07 18:27:10
JavaScript
Alexander Petrov, 2015-12-07 18:27:10

How to make "enter" event on mobile keyboard?

There is a mobile version of the site. There is a search field. I want to be able to enter text and to search, I had to press the "enter" button (so it's on ios, I don't remember on android). What event should be hung?
Did this first:

$('.search_input').keypress(function(){
        var value=$('.search_input').val();
        window.location='/search_products/?q='+value;
    });

It worked on android, but on iPhone, every time you press a letter, the page refreshes.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2015-12-07
@bingo347

Changing window.location causes page reload,
do it on ajax/websocket

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question