Last active
July 18, 2022 13:04
-
-
Save paulius-sladkevicius/ed6b74d87eb6c9edad1c2c3b4e482c09 to your computer and use it in GitHub Desktop.
Emulation/simulation barcode reader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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