API: Return Input From Keyboard Wedge Device

Receive data from keyboard wedge devices, such as keyboards & scanners. These types of peripherals can connect via Bluetooth or USB.

A keyboard wedge device uses the iPad's native connection for keyboards to emulate keyboard input. This means that while the device is directly connected to the iPad, no on-screen keyboard will be shown when an input field is focused. As a result, we do not recommend using this type of device for projects where visitors would need access to the on-screen keyboard. Use of these devices can also interfere with other types of inputs (for example, drop-down menus).

There are two primary API calls - one that triggers an alert popup requesting a scan (with customizable text) and one that listens in the background for scanner data. Data encoded in the barcode or QR code is returned as a string to your page through a JavaScript callback.

Requirements

Kiosk Pro Enterprise

  • Integration of our JavaScript API into your webpage
    • Sample code to run within the app and download for integration into your own project is available here.
    • Best practices for working with the JavaScript API are available here.
  • App Settings
    • Content > JavaScript API > Access JavaScript API = By Import
  • iOS/iPadOS Permissions
    • Bluetooth (if your device connects via Bluetooth) - more on enabling specific iOS/iPadOS permissions here


Triggers via API Functions

Request Data

This function starts requesting data from the connected keyboard wedge device. When triggered, an alert will appear requesting data input.

Format
kp_BluetoothBarcodeScanner_requestAcceptingData(alertTitle, alertMessage, duration);
		
Parameters
  • alertTitle - [string] the title to be shown in the alert
  • alertMessage - [string] the message to be shown in the alert
  • duration - [integer] the amount of time to allow data input, in seconds


Silently Request Data

This function starts requesting data from the connected keyboard wedge device. No alert will appear when triggered.

Format
kp_BluetoothBarcodeScanner_requestSilentAcceptingData();
		


Notifications via API Callbacks

When Data is Returned

This callback triggers when data is successfully returned from the device.

Format
kp_BluetoothBarcodeScanner_dataAcceptingDidFinishWithDataEx(data, arrayOfAllSessionKeypresses);
		
Return values
  • data - [string] interpreted data from the device as a string.
  • arrayOfAllSessionKeypresses - [associative array] all keypresses during data request, including accepted characters and control characters.

  • When Data Fails to Return

    This callback triggers when data fails to return due to an error.

    Format
    kp_BluetoothBarcodeScanner_dataAcceptingDidFailWithError(errorCode);
    		
    Return values
    • errorCode - [integer] error code. Possible values are:
      • -1000 - data has already been requested & the scanner is currently busy.


    When Data Request Timeout Occurs

    This callback is triggered after the timeout period defined as a parameter in kp_BluetoothBarcodeScanner_requestAcceptingData if no data has been successfully returned by the device.

    Format
    kp_BluetoothBarcodeScanner_dataAcceptingDidFinishWithTimeout();
    		


    When Data Request is Cancelled

    This callback is triggered when a data request from kp_BluetoothBarcodeScanner_requestAcceptingData is cancelled by the visitor.

    Format
    kp_BluetoothBarcodeScanner_dataAcceptingDidFinishWithTimeout();
    		


    Sample Code

    • This sample code relies on the JavaScript APIs built into Kiosk Pro and will not run successfully in other browsers or within our in-app help interface.
    • To run sample code, set the app's homepage to https://kioskgroup.com/keyboard-wedge-api
    • To download a .zip of sample code, click here.

    Change Log

    • Added in version 3.3. Updated in 10.0 to include support for keyboard wedge devices other than Bluetooth scanners.

    Still stuck? How can we help? How can we help?