Keypad typing in sequence

I made a little keypad out of buttons in Dashboard, and I'm simply trying to set it up so when you click 1, it sends out the "1", then 2, it would send "12", then 3, it sends out "123", and so on.


The way I have set up now works; using the "file" node and the "file in", appending each input and sending it, then the little X button there overwrites the file with nothing so you can start again from scratch. It works OK, but it feels inelegant, and there's also a small delay in the output sometimes, so I'm wondering if that's because of this method.
I found another post on here that is exactly this, but his was dependent on a time frame for the input, and I want you to type and clear willy nilly. I couldn't figure out how to derive a solution for me from that post.
Thanks for the help!

Hope this helps, using a function node and flow.set to hold the data.

[{"id":"68b44061.6de018","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"dc59eaef.1681c","type":"ui_button","z":"68b44061.6de018","name":"","group":"6293e9bc.df8968","order":2,"width":0,"height":0,"passthru":false,"label":"1","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"num","topic":"keyboard","x":350,"y":180,"wires":[["e9f291d1.a4dfe"]]},{"id":"e9f291d1.a4dfe","type":"function","z":"68b44061.6de018","name":"","func":"if (msg.payload ===\"x\") {\n    flow.set(\"numbers\", \"\");\n    return {};\n}else{\n    var hold = (flow.get(\"numbers\") || \"\") + msg.payload;\n    flow.set(\"numbers\", hold);\n    msg.payload = hold;\n    return msg;\n}","outputs":1,"noerr":0,"x":520,"y":220,"wires":[["6ca8e1d0.6153b8"]]},{"id":"86a05172.0ecfb8","type":"ui_button","z":"68b44061.6de018","name":"","group":"6293e9bc.df8968","order":2,"width":0,"height":0,"passthru":false,"label":"2","tooltip":"","color":"","bgcolor":"","icon":"","payload":"2","payloadType":"num","topic":"keyboard","x":350,"y":220,"wires":[["e9f291d1.a4dfe"]]},{"id":"c3693577.392be8","type":"ui_button","z":"68b44061.6de018","name":"","group":"6293e9bc.df8968","order":2,"width":0,"height":0,"passthru":false,"label":"3","tooltip":"","color":"","bgcolor":"","icon":"","payload":"3","payloadType":"num","topic":"keyboard","x":350,"y":260,"wires":[["e9f291d1.a4dfe"]]},{"id":"f4284afd.2a835","type":"ui_button","z":"68b44061.6de018","name":"","group":"6293e9bc.df8968","order":2,"width":0,"height":0,"passthru":false,"label":"x","tooltip":"","color":"","bgcolor":"","icon":"","payload":"x","payloadType":"str","topic":"keyboard","x":349.3333282470703,"y":309.33331298828125,"wires":[["e9f291d1.a4dfe"]]},{"id":"6ca8e1d0.6153b8","type":"ui_text","z":"68b44061.6de018","group":"6293e9bc.df8968","order":5,"width":0,"height":0,"name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":720,"y":240,"wires":[]},{"id":"6293e9bc.df8968","type":"ui_group","z":"","name":"Default","tab":"a1e95e9e.580868","order":1,"disp":false,"width":"6","collapse":false},{"id":"a1e95e9e.580868","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

That's just lovely. Thank you. I'm so mad at myself for not learning this stuff earlier on in life. I seem to have no intuition for programming language. Time to get crackin I guess.
Anyway, this will be very useful for a few other projects as well. Thanks again.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.