Hm, you are right. I think that there is some vital information missing here. I actually thought more than I was writing
I discovered the keyboard widget for doing some text formatting on the fly. First a command is expected, which is checked against a list of known commands. If the command match, a space is automatically inserted and the (internal) input mode switches from letters (=command) to arguments (digits). When the line is finished (enter/return), the internal input mode is being resetted to accept letters (command).
The macro adds each key to the text and therefore I need to append a newline also. Unfortunately the keyboard widget translates this into a string and the event-key
contains enter
or return
and not an appropriate char sequence (which could append a new line to the captured text).
I hope this explanation can clarify my requirement? Below is a simplified version of my code (only for digits).
Regarding the scope of the event-key:
In my first example it is placed inside the $keyboard
-tag. So it should work this way, if I understand it right? But it does not.
It captures the keys right, but it is only visible inside the scope of the macro.
\procedure getkey()
<$action-setfield $field="keypress" $value=<<event-key>> />
<$let source={{{ [{sourcetext!!text}] }}} newtext={{{ [<source>addsuffix<event-key>] }}} >
<$action-setfield $tiddler="sourcetext" $field="text" $value=<<newtext>> />
<$action-setfield $tiddler="$:/temp/refreshtitle" text="new"/>
\end
<$keyboard actions=<<getkey>> key="1 2 3 4 5 6 7 8 9 0" >
<$edit-text tiddler="sourcetext" field="text" refreshTitle="$:/temp/refreshtitle" class="monospaced" /><br>
key:<<event-key>><br>field:{{!!keypress}}
</$keyboard>