I have a form field with a handler that I want to trigger after the user deliberately accepts the value with either return/enter
or tabs to the next field. I can't use onBlur in this case, since it of course triggers if the user or system blur the field. I only want it on a keyup.
So I have this. I had the enter
first, and it works great. But the keycode==9
does not trigger the handler. The focus merely moves to the next field.
ng-keyup="($event.keyCode == 13 ||
$event.keyCode == 9)
&& packages.submitNumber('add', packages.addTrackingNumber)"
Is there a way to have this fire on enter
OR tab
?
Tab button in html is tabulating to the next focusable element (buttons, inputs etc.). So when you keydown tab button keyup is happening on the next focusable.
To avoid this you can try to use ng-keydown
.
See working example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With