Hacker News new | ask | show | jobs
by nkellenicki 1800 days ago
Focus can be set automatically in the desired field using Javascript, and tricks can be done to hide that field too - ie. set opacity so it's transparent, etc. You can make it work pretty smoothly for the end user.

Some of the original Yubikeys worked this way, and there are some barcode scanners out there that emulate keyboards too. I've seen some web based implementations go to great lengths to hide this fact.

2 comments

Still sounds a bit clunky, as you would have people in line, and the page would need to smoothly be ready for the next person, deal with double-scans of the card, etc.

I'd certainly prefer something like un-typeable keycodes to listen for as start/end markers.

> deal with double-scans of the card,

Presumably you know the length of the string generated by the barcode reader, so you just set the max length of the text field to that length, and/or ignore anything longer via JS.

Focus can also be set automatically on page load by adding the HTML ‘autofocus’ attribute to the input field.