Please note that I have no affiliation with the two links in the next paragraph, nor am I recommending the products. I linked them purely to clarify what I'm talking about in my question.
The requirement is to have a Blazor page where the users has a pile of RFID key fobs (such as these) and an RFID reader (such as this), and needs to tap each fob on the device, and have the Blazor page register the input. When you tap a fob, the device sends the PC the fob's serial number followed by a carriage return, exactly as if you'd typed this on your keyboard.
I'm struggling to work out how to do this in Blazor. Ideally, I don't want a visible input control on the page, and I certainly don't want one where the user can change the input value. The attention span of the person tapping these fobs will probably be in line with the amount they are getting paid (ie not much!), and I need it to be as simple and fool proof as possible. If there is any chance of them changing the input value or setting the focus on some other element, they almost certainly will.
Disabling, or setting the element to readonly
prevents any input from being accepted, so that doesn't work.
Anyone any idea how I capture the input? I can use an <input>
tag, or the Blazor equivalent, but apart from the problem mentioned above, it has the bigger issue of keeping focus. Whilst I get the input on the first tap, the element loses focus after that, and I haven't managed to work out how to get it back.
I tried the techniques described in answers to this question (and others), but all suffered from the same problem. In most cases, the @ref
to the input element was null. Even when I managed to get a non-null reference to the element, trying to set the focus just didn't work. I didn't get any errors, it just didn't set the focus, so I could only get the input from the first tap.
Anyone any suggestions? Thanks