Reputation: 23
I am working with angular 6. I just got a problem. i have a text-box and a submit button. i want to add a functionality.Input into text box will be either by keyboard or by Bar-code scanner. after input all text the button should be submit automatically in case of bar-code scanner. If i go with OnChange or Keypress event then on every character the button is going to submit in both cases. (Keyboard,Barcode scanner).
I have searched also for if i get the event to predict the scanner input or keyboard input then i will do rest of things.
Upvotes: 0
Views: 810
Reputation: 1084
Try something like this.
In you html add keyup event.
<input type="text" (keyup)="onKeyUp()">
Then call your submit function after a timeout like this.
onKeyUp() {
lsetTimeout(() => {
submitFunction();
}, 3000);
}
Upvotes: 1