7

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?

asked Jul 21, 2015 at 12:38

1 Answer 1

7

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

answered Jul 21, 2015 at 12:58
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.