Fire Trigger button from keyboard keys

brother help me uneed to use trigger button in node red can you help me to do it i found you got solution it .also need help can we connect keyboard keys to fire trigger button .

brother help me uneed to use trigger button in node red can you help me to do it i found you got solution it .also need help can we connect keyboard keys to fire trigger button . waiting for your reply

@raatech91 Please don't tag (or post duplicate) posts into someone else's topic.

Perhaps a mod can move this into it's own topic??

bro i donk know to send messsage directly .and that topic closed so i contack in recent post

@raatech91 I've moved your posts here, in their own topic.

1 Like

@raatech91 what have you tried on your own so far?

Have you searched the palette for the keyword keyboard?

Yes but it doesn't work also used keypress node ,idont know problem is mine or in node red

Where is the keyboard connected? To the same hardware where node-red is running?

@raatech91 You haven't really shown what you have tried, or even really need (in detail).

I have tested some of the keyboard nodes, and two wouldn't even install, but the one from node-red-node-pi-gpio sorta worked... at least the Mouse node did, the Keyboard node just repeatedly flipped from connected to not connected. (for that node, the USB Mouse & Keyboard must be connected to the RPi)

Meanwhile... this is a (poorly hacked) add-on to an excellent example from @Steve-Mcl, that he had provided here. It works on the keyboard that is used with whatever runs the dashboard browser.

It might give you something to work with.

image

[{"id":"b732a0c7f2d6d3b4","type":"ui_led","z":"534ee29537236d51","order":3,"group":"a348b0ef9d248038","width":2,"height":2,"label":"","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"#008000","value":"up","valueType":"str"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"","x":830,"y":260,"wires":[]},{"id":"4f4c0499780251e2","type":"ui_led","z":"534ee29537236d51","order":7,"group":"a348b0ef9d248038","width":2,"height":2,"label":"","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"#008000","value":"down","valueType":"str"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"","x":830,"y":340,"wires":[]},{"id":"4b8858eed7f9d5f8","type":"ui_led","z":"534ee29537236d51","order":6,"group":"a348b0ef9d248038","width":2,"height":2,"label":"","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"#008000","value":"right","valueType":"str"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"","x":950,"y":300,"wires":[]},{"id":"f2ccef4bf96840f3","type":"ui_led","z":"534ee29537236d51","order":5,"group":"a348b0ef9d248038","width":2,"height":2,"label":"","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"#008000","value":"left","valueType":"str"}],"allowColorForValueInMessage":false,"shape":"square","showGlow":true,"name":"","x":710,"y":300,"wires":[]},{"id":"6b39130a6aadae20","type":"ui_template","z":"534ee29537236d51","group":"a348b0ef9d248038","name":"","order":1,"width":0,"height":0,"format":"<div id=\"key_press\">Press Arrow Key</div>\n<script type=\"text/javascript\">\n(function(scope) {\n  const _scope = scope;\n  $('body').on(\"keydown\", function(e) { \n            var keyCode = (e || event || {}).keyCode;\n      if(keyCode >= 37 && keyCode <= 40) {\n        _scope.send({payload: keyCode});\n      }\n  });\n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":160,"y":280,"wires":[["4f89730c0a377ddb"]]},{"id":"4f89730c0a377ddb","type":"rbe","z":"534ee29537236d51","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":330,"y":280,"wires":[["55b281b79fc39c90"]]},{"id":"83ed5dffb05cae95","type":"function","z":"534ee29537236d51","name":"","func":"msg.payload=\"\"; \nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":220,"wires":[["4f89730c0a377ddb"]]},{"id":"5b6e58ae4cd1fb43","type":"delay","z":"534ee29537236d51","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":530,"y":280,"wires":[["83ed5dffb05cae95"]]},{"id":"55b281b79fc39c90","type":"function","z":"534ee29537236d51","name":"","func":"let key = msg.payload;\nif (key == 37) {\n    msg.payload = \"left\";\n} else if (key == 38) {\n    msg.payload = \"up\";\n} else if (key == 39) {\n    msg.payload = \"right\";\n} else if (key == 40) {\n    msg.payload = \"down\";\n} else {\n    msg.payload = \"\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":340,"wires":[["f2ccef4bf96840f3","b732a0c7f2d6d3b4","4b8858eed7f9d5f8","4f4c0499780251e2","5b6e58ae4cd1fb43","207dcddfb93e5e9e"]]},{"id":"207dcddfb93e5e9e","type":"debug","z":"534ee29537236d51","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":400,"wires":[]},{"id":"a348b0ef9d248038","type":"ui_group","name":"Default","tab":"3316deba5234ba30","order":1,"disp":true,"width":"6","collapse":false},{"id":"3316deba5234ba30","type":"ui_tab","name":"test","icon":"dashboard","disabled":false,"hidden":false}]
2 Likes

what we have to place in the led node (rpi led)

↑ Answer ↑ ?

When you say "can we connect keyboard keys to fire trigger button" what is "fire trigger button"?

What are you actually trying to do? Switch GPIO outputs on/off from keyboard presses?

i need to control rpi gpio through keyboard keys- up, down, left, right. when we press the key (gpio out) led glow when we release led off ..... i need to create this only...

I cant help if you dont answer.

Where is the keyboard connected? To the same hardware where node-red is running?

yes bro you re correct i am not genius i dont know more about node red...

? I didnt say you were not - I simply asked if the the keyboard is connected to the same device where node-red is running - which you still have not answered.

yes bro i agree what you say.now re u satisfied with my answer

No, you havent answered.

ok what is the answer .i failed to answer your question . now you tell what is the answer

image

image

Where is the keyboard connected? To the same hardware where node-red is running? am i correct now