Jquery. autocomplete modification example for Automatic Filling of up and down keys on the keyboard

Source: Internet
Author: User

You can use the keyboard to move up or down to obtain values in the Lenovo menu as needed, just like google baidu's query function.
I have not found any plug-ins that can implement this function for a long time on the Internet. Instead, I can only change the code by myself.
Find the KEY. DOWN and KEY. UP in js and execute the code.
As follows:
Copy codeThe Code is as follows:
Case KEY. DOWN:
Event. preventDefault ();
If (select. visible ()){
Select. next ();
}
Else {
OnChange (0, true );
}
Break;

After select. next ();
Copy codeThe Code is as follows:
Var selected = select. selected ();
Var v = selected. result;
$ Input. val (v );

In this way, the corresponding value is displayed in the input box when the up and down keys are enabled, but the cursor on the Lenovo keyboard is gone.
Find the definition of select. next (); Code
Copy codeThe Code is as follows:
Next: function (){
MoveSelect (1 );
},

Add a similar method
Copy codeThe Code is as follows:
Stay: function (){
MoveSelect (1 );
},

Then
Copy codeThe Code is as follows:
Case KEY. DOWN:
Event. preventDefault ();
If (select. visible ()){
Select. next ();
Var selected = select. selected ();
Var v = selected. result;
$ Input. val (v );
Select. stay ();
}
Else {
OnChange (0, true );
}
Break;

In this way, you can.

======================================

Thank you very much for the original author,

Add a similar method
Copy codeThe Code is as follows:
Stay: function (){
MoveSelect (1 );
}, And then found to click the upper and lower keys, is to move across rows, so changed:

Stay: function (){
MoveSelect (0 );
},

Related Article

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.