External barcode scanner listenner

Hello there.

I need to create a app that reads data from EXTERNAL barcode scanner i can’t use the barcode scanner plugin, once it displays the camera instead the external barcode scanner).

When the external barcode scanner reads some data, is like write some text in a input and press ENTER, so i implemented the following code. It works fine in my Motorola MC40 (https://www.zebra.com/br/pt/products/mobile-computers/handheld/mc40-mobile-computer-series.html).

@HostListener('window:keypress', ['$event'])
  keyEvent(event: KeyboardEvent) {
      this.leitura+= event.key;

But, when i try it on oldest devices like WinMate M700DM4 (http://www.winmate.com.tw/TabletPC/TabletPCSpec.asp?Prod=13_0186) or WinMate E430M2 (http://www.winmate.com.tw/newsletter/Newsletter20130719.htm) the scanner does not display.

Can i use the barcode sacnner plugin to display external scanner?

The barcode scanner plugin uses a device camera to read a barcode and then save the scanned barcode in a variable your program can use.

The code you wrote listens for specific keypresses and if it matches a keycode adds something to a variable.

How do you want to mix these two methods?
Isn’t your problem that your code doesn’t work on some devices? Why doesn’t it work therE?

I’m not using the barcode scanner plugin.

The code i wrote handle the default behavior of external barcode scanner (get the value of barcode and press ENTER).

But, in some devides, when the app builds the button that trigger the external barcode scanner doesn’t work anymore. When i press the button a laser must appear to scan the barcode, but nothing happens…

Does the barcode scanner work in other apps whree you can type stuff, e.g. Messages? As far as I know these barcode scanner devices just send keyboard input to the device. If the laser is off, this seems more like a hardware/compatibility problem than a software problem.

Yes, it works in others apps.

I created a blank project with ionic2, and after the splash the trigger button stops to work.

Maybe creating my own plugin to display the external scanner solve my problem …

Why should it? Your scanner is just an external keyboard. Or is there any other code to make it work? Do other apps require any other changes for the scanner to work?

On all devices or only the specific ones you mentioned?

Only the specific ones i mentioned. I think it’s a hardware/compatibility as you said. But i can’t undestand why it works on all apps but the ionic ones.

Yes, that’s what is confusing me too and why I am asking so many questions.

Could you describa again how exactly you know it doesn’t work anymore and when this happens?

Hello, i solved the problem :slight_smile:

The device listen for a specific broadcast. So i’ve created a plugin that sends it globaly (the broadcast plugin sends broadscast only in app-leve by LocalBroadcastManager).

Sorry for the late and thanks for your help.


Awesome. Could you upload the plugin to Github and share the link here? I’m sure this could be useful for other people, too.

1 Like

How did you solve it? Can you post your code?

Please add code