I have the following directive to move to the next input after the field is filled in, for that I have the Following code on my directive:
function moveNextInput() {
return {
restrict: 'A',
link: function ($scope, element) {
element.on("input", function (e) {
if (element.val().length == element.attr("maxlength")) {
var $nextElement = element.next();
if ($nextElement.length) {
$nextElement[0].focus();
} });
}
};
}
I want to make the opposite of this happen, when pressed to delete/backspace, on mobile input, I want to navigate to the previous input.
My input is as the following illustration:
before filling: _ _ _
after filling (example): 1 2 3
how to make this happen? I am having trouble detecting that delete was pressed.