android - How can we capture a mobile device "Next" button key press in Javascript - Stack Overflow

Most keys on a mobile smartphone keyboard produce a keycode with the following code, however the "

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.

Share Improve this question edited Aug 11, 2019 at 18:29 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Mar 5, 2015 at 20:54 m4gikm4gik 4505 silver badges27 bronze badges 1
  • 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
Add a ment  | 

3 Answers 3

Reset to default 5

Perhaps 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信