I have to set a focus on the text field depending upon the key event I get from BarCode gun instead of keyboard key event.How should I differentiate these key event ?
In my experience it's not possible.
Not without a little bit wizardry. For example if you scan something with a barcode gun the text gets typed much faster than any human could possible type but still slower than copy/paste.
So analyse the speed and the content.
It gets very easy when you want to scan validatable Barcodes.
last_up = 0
input_cache = ""
key_up(key) {
if ((time.now() - last_up) > 1) {// seconds
input_cache = ""
last_up = 0
} else {
input_cache += key
if (IsValidBarcode(input_cache)) {
doSomething()
}
}
last_up = time.now()
}
Many barcode readers can be configured to send a prefix before the actual content of the barcode. This prefix could either be a string, or specific key strokes (like F12 or Ctrl+B).
You can use this feature to detect an incoming barcode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With