I\'m trying to process input from a barcode scanner in a javascript browser app. The scanner output is a string of characters, which also contains at least one Group Separator c
Inspired by Sebastian G, this option allows to catch all Alt
+ number
codes.
This doesn't work on IE however.
var altvalue = '';
document.getElementById('scanfield').addEventListener('keydown', function (e) {
if (e.altKey) {
if (e.keyCode !== 18 /* ALT key */) { altvalue += e.key; }
}
});
document.getElementById('scanfield').addEventListener('keyup', function (e) {
if (e.altKey === false && altvalue != '') {
this.value += String.fromCharCode(parseInt(altvalue));
altvalue = '';
}
});