Skip to content

Instantly share code, notes, and snippets.

@paulius-sladkevicius
Last active July 18, 2022 13:04
Show Gist options
  • Save paulius-sladkevicius/ed6b74d87eb6c9edad1c2c3b4e482c09 to your computer and use it in GitHub Desktop.
Save paulius-sladkevicius/ed6b74d87eb6c9edad1c2c3b4e482c09 to your computer and use it in GitHub Desktop.
Emulation/simulation barcode reader
function simulateBarcodeScan(barcode) {
function simulateKeycode(keycode) {
return $('body').trigger($.Event('keypress', {which: keycode, keyCode: keycode}));
}
for (var i = 0; i < barcode.length; i++) {
simulateKeycode(barcode.charCodeAt(i));
}
simulateKeycode(13); // Enter
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment