M
M
Marat2016-03-20 20:59:44
JavaScript
Marat, 2016-03-20 20:59:44

Does usb rfid reader work in keyboard emulation mode in a web application?

Hello, I'm interested in a conceptual approach to solving the problem of usb-rfid reader operation in keyboard emulation mode in a web application, the bottom line is that the data from touching a card with an rfid reader enters any active text field in the format of a set of simple numbers in an amount of 10.

Task: in that, regardless of the focus on any text field, select the card id code data and send it for further processing.
Also, the task is not to interfere with user input in any field.

Note that the information received from the reader has several distinctive properties from user input: the data output time between 1 and the next digit takes no more than 18 milliseconds. i.e. a person will not be able to dial faster.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrzej Wielski, 2016-03-21
@wielski

If we take into account only the input speed (no more than 20 ms), then something like this:

var RFIDTime = false;
var RFIDInput = '';
$(document).keyup(function(e){
   if(!RFIDTime) RFIDInput += String.fromCharCode(e.which); RFIDTime = e.timeStamp;
   
   if(RFIDTime){
     if(e.timeStamp - RFIDTime < 20){
       RFIDInput += String.fromCharCode(e.which);
       RFIDTime = e.timeStamp;
       if(RFIDInput.length == 10){
         console.log('RFID detected, value: ' + RFIDInput);
       }
     } else {
       RFIDInput = '';
       RFIDTime = false;
     }
   }
});

But if you enter something very quickly on the keyboard (hit it), then this will also be defined as RFID. In this case, it is worth checking the entered data on the backend.
If some input is focused, then the data will be entered into it.
There is no way to avoid this except by storing the previous value in a variable and returning it back if the server returned true as valid (RFID passed).

R
Roman Yakovlev, 2019-06-19
@geonaroman

Марат, добрый день! Подскажите, пожалуйста, как решили данный вопрос, что из этого вышло?
Сейчас тоже встрял на этом моменте, но решений пока не вижу...
Буду очень рад, если сможете ответить мне..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question