Context:
I'm working on a web application that uses a barcode scanner device. Users scan barcodes, I redirect them to the appropriated page.
Problem:
The scan device I'm using triggers "keypress" events ONLY when the user is in a input box element
window.addEventListener("keypress", function (event) {
// do something with the event
}
I would like to be able to scan barcodes from ANYWHERE in my application (even when I'm not in an input box). (Yes I know that the code above will fire for every character, I have a timer based algorithm to know if it's a barcode reader or a person typing.).
So far :
I looked at this, so I tried to replace the accepted solution's selector with a more general selector (window or document) without luck. Is there other events more appropriated for this task? I'm open to suggestions on doing it another way.
--EDIT-- :
After more research I came across this. The problem is that my view might not have any input. Just plain text
Thank you