<script>
var barcode = '';
document.addEventListener("keydown", function (e) {
const textInput = String.fromCharCode(e.keyCode);
if (e.keyCode == 13 && barcode.length >= 3) {
console.log('barcode scanned: ' + barcode);
barcode = '';
} else {
barcode += textInput;
}
});
</script>