Getting Special Characters $ % @ as Key Input

I am trying t let the user input special characters ( those with shift, alt, ctrl ) into the experiment.
In order to get “@” I get the key response ‘lshift’ ‘2’ which I could handle, but the software will run in 4 different countries with different keyboard layout. There the symbol is at ‘alt’,‘ctrl’,‘2’ or ‘alt’,‘ctrl’,‘q’.
This makes it very inconvenient to create the language (keyboard setting) code to combining the multi-key entries.
Any suggestion ( I am a rather Newbee, however, my current experiment is already heavily Python modified )


Are you using the new TextBox component, or handling the text input yourself in code, keypress-by-keypress?

Not using TEXTBOX,

had seen Form but overlooked that option.

Thanks for the pointer, as I said: I am a newby

My underlying problem is: I run the experiment as a standalone in a loop, thus could not find a way to ask certain people for their contact info (based on the responses).

I will get back to you.




I am too dense:

textbox only seems to “show” me text. My problem is that I need to get a string like “john_$3@jenny.what” INTO the program.

Once I have the strokes inside Python I am fine. It is that “@” and “)” come through as combined key-strokes that are different on international keyboard layouts

Am I misunderstanding ?


Sorry Michael, forgot to add this:

I tried

but when I type “*@(” it tells me “829” when I use a German Layout it gets me “controlqPLUS8”

Checking that for US, Germany, Italy, Norway can be a problem, since there might be ö ä å æ ø .


But the texbox gives you the correct input, right? (i.e. the actual characters you want rather than the set of keypresses required to type them.) So once the routine ends, you should just be able to get the content of the textbox into a variable and do what you want with it.

e.g. in the “end routine” tab of a code component, put something like this:

subject_response = your_textbox_component_name.text


somehow I think I misunderstand:

I am using textbox, I click “editable”:


On screen I get my mouse and the following:

(I can move the mouse, I can position the cursor on any of the characters, but I can not edit, not type )


( did set my color so I could see the box )

What am I missing ?


Do you have a code component setting textbox.text ?

If so, then I think you should switch “set every frame” to constant because at the moment it’s resetting the text to Type here every frame.

I have no experience with editable text boxes (yet).

1 Like

I think Wakefield is on the money here, if you are setting text then it will set it from the Code component each frame, overriding whatever has been inputted to the Textbox! If you try making a new experiment with just a textbox in, does it still have this problem?

To Mike:
no, I do not get the textbox to show me anything. If I can get the box to have my typed data, I would be fine.

To Wake &TP:
I tried empty text boxes, etc. As soon as the textbox appears, the mouse becomes active, but no input is shown. I tried “constant” and “set every frame”.
Again, I am not trying to “output” text, I am trying to read special characters like § $ @ which are on different keyboard locations as a function of the country you are in. I can not simply use the language of the experiment as an indicator ( I am changing the displayed text as a function of the desired language ) because the keyboard and the language are different. I have 3 keyboards attached to my US-language computer ( 2 real, 1 virtual )

Shortened Problem Statement
the immediate problem is:
during the test I need to read the e-mail address of the person taking the test.
This has to be done from within the program, since it runs in a loop in a public hallway.


Then this is the only issue that needs to be solved. The TextBox component should work as-is, with no custom code needed at all.

I think the issue is that in your component, you have selected to update on every frame. That means the content will just keep getting reset to “Type here”, regardless of what the subject types. Change that to “Constant” instead. That means it will be initialised to “Type here”, but can subsequently be edited. I know you said above that you had tried changing these settings, but I wonder if there was still some conflict with your custom code there. If you create a fresh Builder experiment containing nothing other than an editable textbox, you should see how the update settings work.

I think the terminology in the update settings for this component don’t carry over very well from the way they work in other components - it is a new feature, and this misunderstanding shows that it might need to be tweaked.

@jon: perhaps we need to rethink the labels here for this specific component, as they seem contradictory when the “editable” setting is applied. i.e. “constant” actually means “editable”, while “every frame” means “constant” (unless the content of the text field is a code expression I guess). This is tricky, as the meanings shift depending on whether the mode is set to editable or not, and whether the content in the text field is static or a code expression.

thanks a lot and @jon is also on the mark:
Of all the items I tried, I never thought about an active input as “constant”. Now I have to figure out how the string is named ( I assume the standard textbox.keys ), so still work ahead, but you help was valuable ( never understood why it would be good to be non valuable, as in invaluable . . . . , but english is my 2nd language, so what do I now)

No it is like the standard text component, as suggested above:

That is, the TextBox component doesn’t collect raw keypresses: it stores the resulting characters (e.g. it doesn’t record whether someone pushed the shift key, it just gives the resulting capital letter or symbol).

Michael, thanks.

One more question to textbox:
is there a fast way to terminate ?
I see “condition” but so far have only been able to terminate using escape.
Or do I have to write the code to check the string for specific characters inside the routine ?


Forgot: I already did the string testing, but wondered if textbox has a faster way to do terminate.