Hi, iam working on an app, which i need to use on terminal with laser barcode scanner. Problem is, that i cant acces laser barcode scanner with default barcode plugin and iam not a java programmer, so iam not able to write cordova plugin myself.
A think of a possible workaround - scanner can be configured to send the scanned data as focus or keyboard input. My idea was, that i will create hidden input in home page of my app, and i will focus it. Then when i scan barcode, it will go to hidden input, where i can get it with onChange listener. Any ideas how to implement this?
i tried it with template variable and viewChild, but i was not able to get it work. Is there a way to do this? Or can i listen to keyboard input globally and filter it somehow?
here are snippets of my code:
template:
<ion-input #hiddenInput autofocus="true" type="hidden" (ionChange)="inputChanged($event)"></ion-input>
<ion-button (click)="focusHidden()">
focus hidden
</ion-button>
ts file:
export class HomePage implements OnInit {
@ViewChild("hiddenInput", { static: true }) hiddenInput: any;
inputChanged(event) {
console.log(event);
}
focusHidden() {
console.log(this.hiddenInput);
this.hiddenInput.setFocus();
}
}