I need to grab input from barcode scanner, which works exactly as keyboard, only it "types" a lot faster. There are no delimiters, no line endings. Virtually no way of comparing scalar values - whatever's been entered by a user might look exactly as a barcode.
I guess it is possible with Rx, since barcode scans a lot faster than any user can type.
How can I create an Observable from document.keypress
event that distinguishes user input from barcode scanner's?
I'm guessing it should somehow buffer/window values whenever there's a "burst" of keypresses and then a pause between.
Doing this, still not helping:
Rx.Observable.fromEvent(document, 'keypress')
.bufferWithTime(1500)
.filter((x)=> _.isNotEmpty(x) && x.length > 5)
It just grabs whatever was typed every one and a half seconds. Can you guys help me to wrap my head around this thing?