No, you do not need focus on a specific input field. The code that listens for keystrokes is as follows:
$(document).bind('keydown', function(e) {
The module itself is quite small and self contained, so you shouldn't to my knowledge encounter any stability issues. From a high level standpoint the module does the following:
- Listens for keystrokes on the website that happen in a user defined interval.
- Creates a path at barcode-scanner/trigger-event/XXX to receive the barcode from the browser.
- Triggers a rules event with the context of a product and product display.
You will need to configure a rule to respond to the barcode scans and you will also need to assign the "trigger commerce barcode events" appropriately, only users who are assigned that permission will be able to trigger the configured rules events.
If you would like to test the module without a barcode scanner on hand, visit "admin/commerce/barcode-scanner" and then set the "Keypress Interval" setting to something large like "5000". This will give you 5 seconds between each keypress before it is discounted as a "scan". This is because barcode scanners usually enter their keys in very fast, so it prevents normal use of the website from being detected as a scan.
Then simply type in your SKU and hit return to simulate a real barcode scan.