I am new to PsychoPy and I have been trying to design a cued recall test for my experiment. In this test, the cue word will be presented to participants with a blank text box next to it, and participants will be asked to type the target word for the presented cue.
n= len(theseKeys)
TypeError: object of type ‘KeyPress’ has no len()
I also attached the ss of the code I used.
Looking at the previous related topics, I think it has something to do with the version of PsychoPy I am using. Any ideas about how to fix this issue? Any help is highly appreciated!
Hi @eylul, I have put together a demo that writes user input on screen, it is similar to your task. It works in native (local) and online PsychoPy. Take a look at the task running at [1], and download a copy for yourself at [2]
Thank you, @dvbridges ! I couldn’t make my code work online but this one works perfectly.
One question: is there any chance to allow input in Cyrillic using this code?
The program (textinput demo) aborts when “backspace” is pressed using some blowers like Firefox. But it works fine with chrome when trying to edit the typed word. Any idea why? I have the same issue with my own experiment when adapting code from the demo.
Hey David, thanks so much for giving us a demo to work from. I followed your link https://run.pavlovia.org/demos/textinput/html/ which worked, thus demonstrating that the javascript version of your code can work.
However, if I try to sync the inputtext.psyexp file to Pavlovia and then run it there, I get a “Unspecified JavaScript error” when I try to run it.
My guess is that you have made some modifications directly to the .js code that you have not yet already made to the “code” component in the “trial” routine of the inputtext.psyexp file.
This is a problem because I want to integrate your free text input routine into an existing experiment so that I can get participant feedback.
Am I correct in my guess of why it runs when I follow your HTML link but not when I download the .psyexp file and try to manually run that in Pavlovia
Can you provide an updated inputtext.psyexp file whose code component contains the javascript necessary for it to run online?
@atryan , I could provide another example, but have you tried using textbox2 in the latest PsychoPy? Its an editable textbox that is compatible with Pavlovia - here is a demo
@dvbridges , thanks for your post. I have indeed tried using textbox2 in the latest PsychoPy release (2.2.10). While I could get texbox2 to work in Pavlovia when I created a new experiment from scratch with just the textbox (and a continue button) in it, every time I tried to add it to my existing experiment, it throws a “TypeError: state.toLowerCase is not a function” error every time I try to run it on Pavlovia.
I tried everything I could think of, including:
It runs in the offline version
Tried a different browser and new computer
I thought maybe since I originally created the experiment in an earlier version of psychopy, that maybe Pyschopy Builder was inserting the old non-Pavlovia compatible version of textbox. So I (a) deleted and reinserted the textbox in the experiment, (b) used a different computer with a fresh install of the latest psychopy stand alone, (c) copied the experiment files into a new folder, started a new Pavlovia project, (d) went into the experiment settings and manually selected Psychopy version 2020.2.10.
I tried deselecting the editable option
I tried putting placeholder text in the box
No matter what I did, Pavlovia threw the “state.toLowerCase is not a function” error. The only way I could make it stop is by disabling or deleting the textbox, which then caused the experiment to run fine.
Any thoughts on what might be causing this? I’ve included the output from the Firefox developer console when I ran the experiment below.
Looks like a pixi issue. Specifically the attribute _pixi appears undefined for this textbox object, even though it should read something like _pixi: TextInput {_events: i, _eventsCount: 2, tempDisplayObjectParent: e, transform: t, alpha: 1, … I’m going to flag this one to more expert JS opinion - but the error replicates when I fork your task which is a good start point.
I know this was like 3 years ago for your but this answer actually really helped me as well. I was having an issue with my code and checking vs yours helped me solve it!