How to Detect Enter Key from Scan engine vs Keyboard?

I have a Xamarin app on android and I had a recent feature request from my warehouse team to allow keyboard “enter” to submit certain screens, where usually a barcode scan would submit the screen. I test with my personal Memor K unit (Android 9), but the devices I’m targeting include Skorpio X5s (Android 10).

I discovered that after adding the keyboard enter support, I’m getting double events. The barcode scanner engine is configured to send an Enter key at the end of a scan, and I’m hoping there’s a way to detect where that enter originated.

I looked deep into the KeyEvent object, which has two properties of interest.
(Barcode Scan Enter Key Event) KeyEvent.Device.Name = “Virtual”
(Barcode Scan Enter Key Event) KeyEvent.DeviceId = -1
(Keypad Enter Key Event) KeyEvent.Device.Name = “mtk-kpd”
(Keypad Enter Key Event) KeyEvent.DeviceId = 5

Since I dont have a Skorpio X5 on hand, can I count on device ID and or Device Name to be -1/Virtual? Or, can I count on the physical keyboard name to be mtk-kpd on all the devices?

Hello @Kyle_Hatcher
I’m not sure to perfectly understand the issue. You says that you get double events.

The first setting I would check is “Scanner Settings / Formatting / Label Suffix”. This is a static setting used to add a predefined Suffix. at the end of each code. By default it is set to ‘Enter’ (LF).

The second thought goes to the way your application receives the barcode’s content; if your application used the Datalogic Android SDK to listen for the DecodeEvents (see the DecodeListener sample project) but you keep active the KeyboardWedge system (which is enabled by default on the devices), it is possible that your application senses the final Enter twice. You can check if the Wedge system is enable by looking at Datalogic Settings / Scanner Settings / Wedge / KeyboardWedge.

Anyhow for a more direct support, consider to contact the nearest Datalogic branch or open a tech request via the company’s tech support portal to the get the direct support of one of our Local Specialist.

Simone Callegari
Datalogic Mobile Products Specialist - SW Engineer