Reputation: 450
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.
Upvotes: 8
Views: 4329
Reputation: 6720
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.org/en-US/docs/Web/HTML/Global_attributes/inputmode
Upvotes: 4
Reputation: 675
If you are concerned in capturing when the user moved away from your text field, maybe consider the blur()
JavaScript event?
https://developer.mozilla.org/en-US/docs/Web/Events/blur
Upvotes: 1
Reputation: 1824
Use remote debugging with console output and press those keys to get the code.
Upvotes: -1