Hi,
I've made a template node that may help you, it captures all keys pressed in the browser window, and if it receives an "Enter" key press then sends the key presses as a string payload.
[{"id":"85b23e9.71badc","type":"ui_template","z":"80363def.202","group":"ab6812b4.6e15b","name":"Key Capture","order":2,"width":0,"height":0,"format":"<script>\n(function(scope) {\n var buffer = '';\n\n // Make sure we only have one 'global' key press listener,\n // or we get problems if we do a 'Restart Flows'\n if (window.doKeyPress) {\n window.removeEventListener('keypress', window.doKeyPress);\n }\n \n window.doKeyPress = function (e) {\n if (e.key == 'Enter') {\n scope.send({payload:buffer});\n buffer = '';\n return;\n }\n \n buffer = buffer + e.key;\n };\n\n window.addEventListener('keypress', window.doKeyPress);\n})(this.scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":90,"y":40,"wires":[["f32a12f6.9b677"]]},{"id":"f32a12f6.9b677","type":"debug","z":"80363def.202","name":"Captured Keypresses","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":280,"y":40,"wires":[]},{"id":"ab6812b4.6e15b","type":"ui_group","z":"","name":"Status","tab":"78f99d66.99acc4","order":1,"disp":true,"width":"6","collapse":true},{"id":"78f99d66.99acc4","type":"ui_tab","z":"","name":"Lights","icon":"fa-lightbulb-o","disabled":false,"hidden":false}]
This does what I think you want, or the receiving the scanned code bit anyway, with a couple of assumptions:
- The browser window is selected
- Your scanner does act like a normal keyboard
- It terminates the scan with an 'Enter'
First time I've tried to write a node like this, so let me know if it works for you and how you get on with it.
YMMV,
C. Chinchilla