# Sending mqtt once character at a time

**URL:** <https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389>\
**Category:** Dashboard\
**Tags:** node-red-dashboard\
**Created:** [7 August 2023 19:43 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389 "2023-08-07T19:43:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelgin](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nelgin](https://discourse.nodered.org/u/nelgin)\
**Post date:** [7 August 2023 19:43 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/1 "2023-08-07T19:43:25Z")

</div>

Hi all,

I need to send text one character at a time, as typed, to an mqtt topic, including enter and control codes.

It seems it requires all sorts of workarounds by using input buttons and a send button.

It seems using the ui text input I can do only so much. I'm open to suggestions.

Thanks,

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 August 2023 20:40 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/2 "2023-08-07T20:40:46Z")

</div>

It would be a large security hole if any website could act as a key stroke logger, I doubt this is possible from client side Javascript without some sort of browser plugin, but i could be wrong.

---

<div class="post-metadata">

**Author:** ![nelgin](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nelgin](https://discourse.nodered.org/u/nelgin)\
**Post date:** [7 August 2023 21:24 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/3 "2023-08-07T21:24:09Z")

</div>

ftelnet is able to accomplish this but I don't know the inner workings of it and it's probably way beyond my knowledge of how it all works.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [7 August 2023 23:20 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/4 "2023-08-07T23:20:40Z")

</div>

Can you elaborate on the use case, it seems you want to emulate a terminal program of some sort ?

---

<div class="post-metadata">

**Author:** ![nelgin](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nelgin](https://discourse.nodered.org/u/nelgin)\
**Post date:** [8 August 2023 00:23 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/5 "2023-08-08T00:23:34Z")

</div>

Yes you could say that.

My bulletin board software allows the sysop to spy on a node. Often used for bug reporting and the like. Currently you can only spy on one node at a time. The output from each node is also published to a mqtt topic.

Now, if I want to type something back on the terminal, I would like it to be in real time. Again, each node has its own mqtt input topic that can be subscribed to to push data to the node.

I know this probably isn't something that a mqtt dashboard was supposed to do, but it would be interesting to find a workable solution.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [8 August 2023 02:47 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/6 "2023-08-08T02:47:46Z")

</div>

If you set the delay on the text input to 0ms then it will only send the complete text when you press enter.

Could that fit your needs then ?

---

<div class="post-metadata">

**Author:** ![nelgin](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nelgin](https://discourse.nodered.org/u/nelgin)\
**Post date:** [8 August 2023 02:59 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/7 "2023-08-08T02:59:32Z")

</div>

It will but that's not going to work which is why I said I want it to send each character as its typed.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 August 2023 07:04 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/8 "2023-08-08T07:04:56Z")

</div>

Sending each char is easy, it other keys that is difficult, e.g. return, ctrl c, etc

```auto
[{"id":"6a0760d2438c3725","type":"ui_text_input","z":"b9860b4b9de8c8da","name":"","label":"","tooltip":"","group":"2d4fe667.28f8ba","order":12,"width":0,"height":0,"passthru":false,"mode":"text","delay":"100","topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":140,"y":700,"wires":[["6554c0432a776f21"]]},{"id":"6554c0432a776f21","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$substring($$.payload, -1)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":700,"wires":[["fa71db22acf62d16","ccd50e05ab6af6e8"]]},{"id":"fa71db22acf62d16","type":"ui_text","z":"b9860b4b9de8c8da","group":"2d4fe667.28f8ba","order":13,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":510,"y":720,"wires":[]},{"id":"ccd50e05ab6af6e8","type":"debug","z":"b9860b4b9de8c8da","name":"debug 326","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":470,"y":660,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"18","collapse":false,"className":""},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![nelgin](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nelgin](https://discourse.nodered.org/u/nelgin)\
**Post date:** [9 August 2023 05:00 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/9 "2023-08-09T05:00:17Z")

</div>

OK, I'll take a look. I'm not sure how to use that code you sent but I'll figure it out.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [9 August 2023 06:31 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/10 "2023-08-09T06:31:20Z")

</div>

Here's a suggestion for a 'demo flow' using @E1cid's posting above...  
 ![demo_flow_v2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d00a8a5df8baf93550d50f9b3f5fa198955405e.png)  
 ![dashboard_v3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/1248d094d7b3755fd279d13acf3b0bbc4f1736f8.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 September 2023 06:31 UTC](https://discourse.nodered.org/t/sending-mqtt-once-character-at-a-time/80389/11 "2023-09-08T06:31:31Z")

</div>

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