"Keyboard wedge" app in "Key pressure" mode sends some characters as in "Text injection" mode (Memor K)

The Keyboard wedge app depending on it’s mode sends scanned barcodes to the active View in different ways:

  1. Key pressure mode - as event objects to the onKeyPress() / onKeyDown() methods of the active view
  2. Text injection mode - as strings to the commitText() method of the InputConnection object of the active view (you must properly override the onCreateInputConnection method of the View).

Problem: in mode (1) characters not present on a “standard” keyboard - control characters like 0x1D (Group Separator or FNC1 in GS1 barcodes) and non-ASCII characters like ¥ (Japanese yen symbol) - are sent as if Keyboard wedge were in mode (2). If you don’t override the ** onCreateInputConnection** method and don’t implement the InputConnection interface, you don’t get these characters.

The on-screen keyboard on the same device, and also GBoard and Samsung Keyboard can send these characters in onKeyMultiple event with event.keyCode = KEYCODE_UNKNOWN in event.characters property.

Example: GS1 DataMatrix barcode (10)abc(21)def¥ with actual contents 10abc{FNC1}21def¥ is send like following:

SCAN - onKeyDown()
1 - onKeyDown(), onKeyUp()
SCAN - onKeyUp()
0 - onKeyDown(), onKeyUp()
a - onKeyDown(), onKeyUp()
b - onKeyDown(), onKeyUp()
c - onKeyDown(), onKeyUp()
ENTER - onKeyDown()
{FNC1} - commitText()
ENTER - onKeyUp()
21def¥ - commitText()

It must be a bug.

1 Like

Hello @Andrew_Usachov,

Thank you for your feedback and taking the time to clearly articulate your experience.

I was able to replicate your results on my end.
I will relay this to our developers, but we do have a few workarounds in the meantime.

If you are going to use the Keyboard Wedge, we do recommend the Commit Text mode, as it is the most reliable of the three options.

However, if you are already going through the effort to override methods of InputConnection, you could potentially save yourself a lot of headaches by using the Intent Wedge or an onRead() listener.

Using our SDK you can programmatically enable the Intent Wedge.
Then once enabled you can receive the barcode data in the form of an Android Intent.
One caveat of the Intent Wedge is that, generally, you also need to disable the Keyboard Wedge.

Another, more involved method, would be to use a onRead() listener.
A listener coded into your app would be the most secure and have the lowest overhead.

Both these methods provide the most accurate and reliable data.
This allows you as the developer to have more control over how the data is handled.

The Scan Demo app that comes with all devices, utilizes the onRead() listener.
I tested that and it reliably reads the barcode provided.

Here are some resources on those topics:


Drew Hugentobler
L3 Mobile Computer Specialist Support Engineer

1 Like

In this mode and using Kotlin, how do I get the scanned data then the focused view is other than EditText (e. g. TextView or LinearLayout)?


The Keyboard Wedge is designed to emulate a Keyboard.
Focus would need to be selected before data could be typed.
It is possible to program your app to set focus the first time a view or fragment is opened.
As mentioned above, it sounds like you may have more luck programmatically enabling the Intent Wedge and grabbing the data that way, or registering an onRead() listener.
Then the focus would not need to be selected first.

Drew Hugentobler
L3 Mobile Computer Specialist Support Engineer