admin管理员组文章数量:1386750
I've got a single line of code (no forms involved) here:
<input type="number" min="0" max="9999999" id="inSku" name="inSku">
Before, I was using type="text"
, but on mobile browsers that gave the full keyboard by default and the box in question only takes number inputs. Logically, the mobile browsers will change to an only-number keyboard when they focus on a type="number"
field - however, I am currently relying on a little bit of jQuery
to handle the submission of the content of the form. Here's that code:
$("#inSku").keyup(function (event) {
if (event.keyCode == 13) {
ringItem();
}
});
The problem here being that on the stock android phone keyboard (and I'm assuming a good number of other mobile browsers) - when using the "number" keyboard, the enter key that is on the regular alphanumeric android keyboard has changed to a "next" button. This button in my case takes the text input and sticks it in the address field, not exactly ideal. Is there any way to harness the next button on the keyboard and get that to execute my other javascript function?
I've got a single line of code (no forms involved) here:
<input type="number" min="0" max="9999999" id="inSku" name="inSku">
Before, I was using type="text"
, but on mobile browsers that gave the full keyboard by default and the box in question only takes number inputs. Logically, the mobile browsers will change to an only-number keyboard when they focus on a type="number"
field - however, I am currently relying on a little bit of jQuery
to handle the submission of the content of the form. Here's that code:
$("#inSku").keyup(function (event) {
if (event.keyCode == 13) {
ringItem();
}
});
The problem here being that on the stock android phone keyboard (and I'm assuming a good number of other mobile browsers) - when using the "number" keyboard, the enter key that is on the regular alphanumeric android keyboard has changed to a "next" button. This button in my case takes the text input and sticks it in the address field, not exactly ideal. Is there any way to harness the next button on the keyboard and get that to execute my other javascript function?
Share Improve this question asked Sep 25, 2013 at 22:57 taylorthurlowtaylorthurlow 3,0834 gold badges31 silver badges43 bronze badges 1-
4
For the people who e here looking for the exact keycode as well: The keycode of the next key on Chrome Android is
9
(which is the tab key on desktop keyboards). – nils Commented Sep 17, 2015 at 13:41
2 Answers
Reset to default 2Try
$('#inSku').keyup(function (e) {
alert('Key pressed: ' + e.keyCode);
});
The idea here is to press the next
button and find that key code. Once you do, you can add it to your logic like if (event.keyCode === 13 || event.keyCode === ...)
. You can add as many qualifiers as you need to to support multiple keypads and devices.
This is actually android/chrome detecting the second input on the page and assuming you want to keep filling out the form. How helpful.
The behavior you're experiencing is enterkeyhint="next"
which as the ment above indicates is code for the enter key to press "Tab"/key code 9 for the user.
Disable this by using the enterkeyhint property set to "done" or "search" or "enter"
e.g. <input type="text" enterkeyhint="enter" />
本文标签:
版权声明:本文标题:javascript - Behavior of "enternext" key on mobile browsers when entering into a number field - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744564952a2612989.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论