If this template helps then use it. If not then just delete and start from scratch.
**OS: macOS Catalina 10.15.4
**PsychoPy version: 2020.1.2
**Standard Standalone: YES
What are you trying to achieve?:
Use the input() function from python 3 to get and display words which people have to type.
What did you try to make it work?:
In a very simple routine in the builder with a Text and a Keyboard element, I have as well a Code component with the following code at the binging of the routine.
myText = input("Word: ")
print(myText)
In Spyder, if I run these lines, the first line runs and allows me to type some text until I hit “return”. Then the typed text is stored in the variable “myText” and becomes available to be used for any other purpose (e.g. printing its value as in the second line).
The whole idea is to capture the text being written by participants in the variable “myText” (set to refresh every frame) and use it to continuously update the value of the Text component. The Keyboard component is set to end the routine when “return” is hit.
What specifically went wrong when you tried that?:
However, this does not work as. I have tried different things but I keep getting the error below:
myText = input("Word: ")
EOFError: EOF when reading a line
I already know how to get keyboard responses through the Keyboard component, storing them and updating their value after every frame. Using input() over the usual Keyboard component code to do so has many potential advantages. In particular, I am struggling to be able to get Chinese characters as input from the keyboard and store the text in a variable. When using the input() function in Spyder it works perfectly, however, this cannot be done using the Keyboard component of Psychopy. It seems it was design to capture the moment in which a specific key is pressed, rather than to capture text input.
I wrote a comment in the following unsolved thread in which I explain in more detail how Chinese people usually type characters: [Typing Chinese during Experiment]
Any suggestions?