# Experiment runs fine on PsychoPy but not Pavlovia. (TypeError)

**URL:** https://discourse.psychopy.org/t/experiment-runs-fine-on-psychopy-but-not-pavlovia-typeerror/32567
**Category:** Online experiments
**Created:** [December 24, 2022, 5:06am UTC](https://discourse.psychopy.org/t/experiment-runs-fine-on-psychopy-but-not-pavlovia-typeerror/32567 "2022-12-24T05:06:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Woon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/woon/32/36102_2.png) [@Woon](https://discourse.psychopy.org/u/Woon)
#### Post date: [December 24, 2022, 5:06am UTC](https://discourse.psychopy.org/t/experiment-runs-fine-on-psychopy-but-not-pavlovia-typeerror/32567/1 "2022-12-24T05:06:35Z")

</div>

I am trying to create an experiment where participants input two key responses (sequence does not matter but both must be correct). I have no experience in coding hence the image below was the product of other’s help. The experiment runs fine on psychopy but when I pilot it on pavlovia i get this message ’ TypeError: Cannot read properties of undefined (reading ‘length’)'. I suspect something must have gone wrong in the auto conversion from py to js in psychopy?

 ![code3](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/1/b17450e9063f7f1f36e11fe1b2d34121e1704575.png)

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [December 24, 2022, 9:12am UTC](https://discourse.psychopy.org/t/experiment-runs-fine-on-psychopy-but-not-pavlovia-typeerror/32567/2 "2022-12-24T09:12:09Z")

</div>

You need to check that reap.keys exists before you check it’s length.

Put your code in a conditional clause `if resp.keys:`

---

<div class="post-metadata">

### Author: ![Woon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/woon/32/36102_2.png) [@Woon](https://discourse.psychopy.org/u/Woon)
#### Post date: [December 24, 2022, 10:03am UTC](https://discourse.psychopy.org/t/experiment-runs-fine-on-psychopy-but-not-pavlovia-typeerror/32567/3 "2022-12-24T10:03:03Z")

</div>

Sorry I dont know what that means, my knowledge in coding is basically 0. The valid keys for my experiment are ‘s’ ‘d’ ‘left’ 'right ‘up’ ‘down’. Do i add “if resp.keys: ‘s’ ‘d’ ‘left’ 'right ‘up’ ‘down’” to the beginning of the right section of the screenshot?
