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