Soft keyboard search for mobile phone side

Source: Internet
Author: User
Tags ocaml

Mobile phone soft keyboard to achieve functional requirements of search function

Click on the soft keyboard to achieve the search function of the same click Go to check a lot of articles are basically said to listen to KeyDown events and determine the keyboard key value code, I also tried the key and soft keyboard I have not been able to use this method to achieve my form of the onsubmit method to achieve, That is, the form submitted directly below the code

This part is HTML code

<html><form target="#" id="search_from"> <input class="search_in" type="search" placeholder="请输入关键词" /></form>

This part is the JS code

<script>document.getElementById(‘search_from‘).onsubmit = function(){ alert("123"); yourfun();}
</script>

This basic function is realized.
But then click the Search button often the first time the page will be refreshed, only click the second time will appear the desired effect, so we also need to implement the click page does not refresh

<form target="frameFile" id="search_from">     <input class="search_in" type="search" placeholder="请输入关键词" /> <iframe name=‘frameFile‘ style="display: none;"></iframe></form>

Add an IFRAME tag like this, and the from target to the IFRAME will not change the current page link, will not be refreshed

There are many times we click on the search will appear after a long list, the soft keyboard will cover the user search information, we click on the screen will make the soft keyboard disappears, so the user experience is not very good, so we can add a soft keyboard in the call method

<script>document.getElementById(‘search_from‘).onsubmit = function(e){ yourfun(); document.activeElement.blur();//软键盘收起}
</script>

Ok so some basic needs can be achieved, I hope to have some help, if there are shortcomings also hope that we have a lot of comments.

This is a relatively basic function, like multiple input submissions or more cumbersome functions that need further research

Soft keyboard search for mobile phone side

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.