psychopy.org | Reference | Downloads | Github

Variables for allowKeys aren't supported for JS yet

Hello,

I’d like to reuse a routine in an experiment but the allowed keys need to change from the first to the second use of the routine. This doesn’t seem possible currently as I get an error message Variables for allowKeys aren’t supported for JS yet when compling the script to JS.

Was anybody successful in using a variable to set the allowKeys? Is so how did you achieve this?

Best wishes Jens

Hey Jens,

Never tried this, but perhaps we can invent a workaround using code?

Best, Thomas

Hello Thomas

would be cool. What do you need in addition to the psyexp-file
DearyLiewaldVer2.psyexp (41.9 KB)
and the excel-file
StimSimpChoice.xlsx (9.0 KB)
?

Best Jens

Let’s do it! I don’t really need materials, since I’ll build a bare-bones demo only for this purpose. However, peeking at what your shared does give me a starting point for the specs. Let me check those so that I’m sure:

  1. We’ve got a conditions file with a column with allowed keys, in this format: ['d','f','j','k']
  2. We’ve got a routine that we only want to end when one of those keys is pressed
  3. Of this key we (probably) want to log which key it was and its RT

Hello Thomas,

yes, allowed keys in the first call is ‘space’ and ‘d’,‘f’,‘j’,‘k’ in the second call. Any of the allowed key ends routine, log RT and correctness.

Best wishes Jens

I started writing something, but I encountered a little bug in how PsychoJS parses the list (['d','f'] for example). Let me see what the team says about that, then I’ll continue

Fixing list parsing in PsychoJS will be quite a project in itself, so I made a little workaround for the demo. I think this demo might do what you’re looking for: Thomas Pronk / demo_dynamic_allowedKeys · GitLab

Hello Thomas

that was fast. I check it out next week. Thanks a lot.

Best wishes Jens

1 Like