'How can we capture a mobile device "Next" button key press in Javascript

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.



Solution 1:[1]

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

Solution 2:[2]

Use remote debugging with console output and press those keys to get the code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LJ Wadowski
Solution 2 Joe Johnson