Most keys on a mobile smartphone keyboard produce a keycode with the following code, however the "Next" and "Prev." buttons do not:
$('#txtRegMobileNumber2').keydown(function (e) {
alert('Key pressed: ' + e.keyCode);
});
How can I capture the "Next" button press (equivalent to the arrows in iOS) in Javascript?
This other question may be a duplicate, but seeing as how the code does not work for me I still need help. I've tried using e.which
and keyup()
to no avail.
Most keys on a mobile smartphone keyboard produce a keycode with the following code, however the "Next" and "Prev." buttons do not:
$('#txtRegMobileNumber2').keydown(function (e) {
alert('Key pressed: ' + e.keyCode);
});
How can I capture the "Next" button press (equivalent to the arrows in iOS) in Javascript?
This other question may be a duplicate, but seeing as how the code does not work for me I still need help. I've tried using e.which
and keyup()
to no avail.
- I have had luck in the past with keyup over keydown. Have you tried that? From what I remember keydown was being skipped by some devices. – Ryan Wheale Commented Mar 16, 2015 at 16:00
3 Answers
Reset to default 5Perhaps a bit late answer but this issue can be solved with adding inputmode
property to your input and setting it's value to 'search' thanks to that the "Go"/"Next" button on the keyboard is replaced by "Enter" that behaves the same way as normal enter button on a traditional keyboard.
<input id="txtRegMobileNumber2" inputmode="search"
Docs: https://developer.mozilla/en-US/docs/Web/HTML/Global_attributes/inputmode
If you are concerned in capturing when the user moved away from your text field, maybe consider the blur()
JavaScript event?
https://developer.mozilla/en-US/docs/Web/Events/blur
Use remote debugging with console output and press those keys to get the code.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744120893a4559395.html
评论列表(0条)