You can use javascript to set the value of the disabled text field and get the keypress event data using document.onkeydown = function(e) { ... }
. No need for hidden divs.
I assume that there are other fields on your page, which will make it difficult for you to know when to write the card reader data. Are you fortunate that your credit card reader sends unique character (s) to let you know that keyboard events are coming from the reader, and not from clicking the user? If so, then you can listen to these specific keystrokes, so you donโt have to worry about adjusting the focus. Otherwise, perhaps think of the โRead Credit Cardโ button, which has the on("click")
function set to read the next xx digits.
Here is some debugging code you can use to find out if your reader sends unique characters that you can listen to:
document.onkeydown = function(d) { console.log( d.which ? d.which : window.event.keyCode); };
Perhaps there is some other unique event information when the reader is used. Perhaps check the instruction manual.
Zachb source share