Ability to simulate a physical barcode scanner without having one attached to the test station

Would be nice if the Tulip Player in its Developer options would feature a native option to simulate a physical barcode entry.

This is incredibly useful if a physical test scanner is not around at the time of development.

In the meantime, one can workaround this with a helper function that is defined in the developer console and fired manually.


// helper function
function simulateBarcodeScan(barcode) {
  barcode.split("").forEach((char) => {
    const keyEvent = new KeyboardEvent("keypress", {
      key: char,
      code: char,
      keyCode: char.charCodeAt(0),
    });
    document.dispatchEvent(keyEvent);
  });
  const enterKeyEvent = new KeyboardEvent("keypress", {
    key: "Enter",
    code: "Enter",
    charCode: 13,
  });
  document.dispatchEvent(enterKeyEvent);
}

// fire barcode call
simulateBarcodeScan("123456")