KeyboardBarcode

JourneyApps supports the use of certain devices that use keyboard emulation to scan barcodes.

Version and device compatibility

  • Available from version 4.49.0 of the JourneyApps Container.

  • We have tested on Cino FuzzyScan devices, but any device that uses keyboard emulation should work.

To scan data from a device, a callback is registered using the KeyboardBarcode object:

KeyboardBarcode.register(callback, options);
ParameterTypeDescription

callback

Function

Function that receives a single scanned barcode. Required

options

Object

Object that can be used to configure the scan listener. Optional

The options object can have the following properties:

PropertyTypeDescription

start

String

Character used to indicate that the keyboard should capture the next characters until it reaches the end delimiter. Default: '^'

Optional

end

String

Character used to indicate that the scanned barcode is complete. Default: ' ' (space).

Optional

timeout

Number

Time in milliseconds that the listener allows to scan when it reaches the start character until it gets the end character. If a scan isn't completed in that time, no data will be returned.

Default: 1000 (1 second)

Optional

Example

/* The following function registers a callback to listen for scans that start with a `.` and ends with a ` `, and sets the timeout time to 3 seconds.

The callback receives the `barcode` value as text, and in this example appends it to a view variable called `view.results`.
*/


function register() {
    KeyboardBarcode.register(function(barcode) {
        view.results += barcode + '\n';
    }, {start: '.', end: ' ', timeout: 3000});
}

Since the device registers as a keyboard, it may interfere with normal keyboard inputs. It will only interfere if the user types the start character. Thus, setup the device to use something that a user isn't likely to type if both scanning and text input is required to happen simultaneously. That is why the default value is a caret (^).

When a callback is registered, the user can scan multiple barcodes, and each will trigger the callback specified in the register device. For example, the user can scan multiple barcodes without interacting with the tablet or computer, and scanned barcodes can update the user's view as they are scanned.

Deregistering

If you want to stop scanning, you can deregister the listener by calling:

KeyboardBarcode.deregister();

When leaving a view, the KeyboardBarcode is automatically deregistered. Thus, if you want to scan across multiple views, you have to register it again on that view.

Hardware setup

The hardware device has to be correctly configured to be used. Please see your hardware manufacturer's documentation on how to setup the device you are using.

A few important settings:

  1. It has to be set up in keyboard emulation mode (a.k.a. HID mode)

  2. It has to be configured with a preamble of a single character, used as start in the register function options above.

  3. It has to be configured with a delimiter character, used as end in the register function options above.

  4. It has to be paired with Bluetooth or physically connected according to the manufacturer's instructions.

The Cino FuzzyScan devices uses their own barcodes to scan to configure the device.

Last updated