# Problem with seeing typed words in pavlovia

**URL:** https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012
**Category:** Online experiments
**Created:** [June 5, 2020, 3:40pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012 "2020-06-05T15:40:57Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Eloi\_Puig\_Mayenco1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/eloi_puig_mayenco1/32/8849_2.png) [@Eloi\_Puig\_Mayenco1](https://discourse.psychopy.org/u/Eloi_Puig_Mayenco1)
#### Post date: [June 5, 2020, 3:40pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/1 "2020-06-05T15:40:57Z")

</div>

Hey,

I posted earlier but I will provide more detail here. I am having participants type in some words they see. I want them to see what they have typed. It works fine when I run it on builder. The problem comes when I want to run it with pavlovia:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/6/867bfc2e23b322d985a7262a283bb75d3bce6d6f.png)  
The code I have is the following:

Begin experiment:

PY:  
msg=’ ’  
numkeys=0

Java:  
msg = " ";  
numkeys = 0;

EACH FRAME:  
PY:  
templist=key\_resp\_12.keys  
if templist.count(‘return’)==1:  
key\_resp\_12.keys.pop()  
key\_resp\_12.keys=’’.join(key\_resp\_12.keys)  
key\_resp\_12.rt=key\_resp\_12.rt[0]  
continueRoutine=False  
elif templist.count(‘space’)==1:  
key\_resp\_12.keys.pop()  
elif templist.count(‘lshift’)==1:  
key\_resp\_12.keys.pop()  
elif templist.count(‘backspace’)\>=1 and len(key\_resp\_12.keys)\>=2:  
key\_resp.keys\_12.remove(‘backspace’)  
key\_resp\_12.keys.pop()  
msg=msg[:-1]  
elif templist.count(‘backspace’)\>=1 and len(key\_resp\_12.keys)==1:  
key\_resp\_12.keys.pop()  
elif (len(key\_resp\_12.keys)-1) == numkeys:  
msg=’’  
msg=msg.join(key\_resp\_12.keys)  
numkeys=len(key\_resp\_12.keys)

JAVA:  
templist = key\_resp\_12.keys;  
if ((templist.count(“return”) === 1)) {  
key\_resp\_12.keys.pop();  
key\_resp\_12.keys = “”.join(key\_resp\_12.keys);  
key\_resp\_12.rt = key\_resp\_12.rt[0];  
continueRoutine = false;  
} else {  
if ((templist.count(“space”) === 1)) {  
key\_resp\_12.keys.pop();  
} else {  
if ((templist.count(“lshift”) === 1)) {  
key\_resp\_12.keys.pop();  
} else {  
if (((templist.count(“backspace”) \>= 1) && (key\_resp\_12.keys.length \>= 2))) {  
key\_resp.keys\_12.remove(“backspace”);  
key\_resp\_12.keys.pop();  
msg = msg.slice(0, (- 1));  
} else {  
if (((templist.count(“backspace”) \>= 1) && (key\_resp\_12.keys.length === 1))) {  
key\_resp\_12.keys.pop();  
} else {  
if (((key\_resp\_12.keys.length - 1) === numkeys)) {  
msg = “”;  
msg = msg.join(key\_resp\_12.keys);  
}  
}  
}  
}  
}  
}  
numkeys = key\_resp\_12.keys.length;

In addition, I have this so that it shows it on the screen:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/3/a33196b0974ac6d33134001aab744fc3d785730f.png)  
Does anyone know why I am only getting the problem when running it online?

---

<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: [June 5, 2020, 3:46pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/2 "2020-06-05T15:46:36Z")

</div>

An extra reason for why it won’t work (apart from .join not working the same way in Python and JavaScript) is because you can’t put Python code into Builder components. The Auto translate (and the possibility of manual editing) only works in code components.

> **[PsychoPy Python to Javascript crib sheet](https://docs.google.com/document/d/13jp0QAqQeFlYSjeZS0fDInvgaDzBXjGQNe4VNKbbNHQ/edit?usp=sharing)**
>
> PsychoPy version 2020.1.3Python to Javascript Crib Sheet Compiled by Wakefield Morys-Carter, Oxford Brookes UniversityPlease retweet Psych\_Stats. PsychoPy 2020 has an automatic Python to Javascript translation tool. This document contains...

---

<div class="post-metadata">

### Author: ![Eloi\_Puig\_Mayenco1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/eloi_puig_mayenco1/32/8849_2.png) [@Eloi\_Puig\_Mayenco1](https://discourse.psychopy.org/u/Eloi_Puig_Mayenco1)
#### Post date: [June 5, 2020, 3:49pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/3 "2020-06-05T15:49:31Z")

</div>

But it works when I run it on builder. It was the only way I found to make it display the typed text on the screen.

---

<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: [June 5, 2020, 3:52pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/4 "2020-06-05T15:52:46Z")

</div>

Builder uses Python locally.  
Python doesn’t work online  
PsychoPy uses JavaScript online.  
The languages are different so you can’t expect code that works locally to work online unchanged.

Have a look at [https://pavlovia.org/Wake/brookes-template-2020](https://pavlovia.org/Wake/brookes-template-2020) to see how I have a two digit age typed response online.

---

<div class="post-metadata">

### Author: ![Eloi\_Puig\_Mayenco1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/eloi_puig_mayenco1/32/8849_2.png) [@Eloi\_Puig\_Mayenco1](https://discourse.psychopy.org/u/Eloi_Puig_Mayenco1)
#### Post date: [June 5, 2020, 4:17pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/5 "2020-06-05T16:17:53Z")

</div>

Ok, thanks! So I have looked at your experiment and adapted your age bit to mine. It seems to work again in the builder, but it is giving me a different error when I run it online

- **TypeError: undefined is not an object (evaluating ‘event.clearEvents’)**

---

<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: [June 5, 2020, 4:42pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/6 "2020-06-05T16:42:55Z")

</div>

You need **event=psychoJS.eventManager;** in **code\_JS** for that to work

---

<div class="post-metadata">

### Author: ![Eloi\_Puig\_Mayenco1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/eloi_puig_mayenco1/32/8849_2.png) [@Eloi\_Puig\_Mayenco1](https://discourse.psychopy.org/u/Eloi_Puig_Mayenco1)
#### Post date: [June 5, 2020, 4:50pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/7 "2020-06-05T16:50:07Z")

</div>

> [@wakecarter](#):
>
> code\_JS

Could tell me how to add it?

---

<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: [June 5, 2020, 5:43pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/8 "2020-06-05T17:43:50Z")

</div>

Please could you look at my crib sheet and let me know if my instructions aren’t clear enough

---

<div class="post-metadata">

### Author: ![Eloi\_Puig\_Mayenco1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/eloi_puig_mayenco1/32/8849_2.png) [@Eloi\_Puig\_Mayenco1](https://discourse.psychopy.org/u/Eloi_Puig_Mayenco1)
#### Post date: [June 6, 2020, 10:44am UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/9 "2020-06-06T10:44:45Z")

</div>

> [@wakecarter](#):
>
> event=psychoJS.eventManager;

Hey, thanks for your help. They are clear. I added this to the code\_JS:  
cursorCounter = 0;  
cursorVariable = “|”;  
captured\_string = “”;  
subject\_response\_finished = false;  
event=psychoJS.eventManager;

but I still get the same problem. Do you know why?

---

<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: [June 6, 2020, 12:33pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/10 "2020-06-06T12:33:01Z")

</div>

Please could you show screenshots of the two relevant code components? Alternatively, if you make the experiment public or share it with me I can take a look.

---

<div class="post-metadata">

### Author: ![Eloi\_Puig\_Mayenco1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/eloi_puig_mayenco1/32/8849_2.png) [@Eloi\_Puig\_Mayenco1](https://discourse.psychopy.org/u/Eloi_Puig_Mayenco1)
#### Post date: [June 6, 2020, 12:38pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/11 "2020-06-06T12:38:40Z")

</div>

Hey Wakecarter,

I think I made it work. I owe you a big ONE! truly thankful. I hope you don’t mind if I ask something else… it only allows me to type in 2 characters, do you know how I should do it to type in more characters?

---

<div class="post-metadata">

### Author: ![Eloi\_Puig\_Mayenco1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/eloi_puig_mayenco1/32/8849_2.png) [@Eloi\_Puig\_Mayenco1](https://discourse.psychopy.org/u/Eloi_Puig_Mayenco1)
#### Post date: [June 6, 2020, 12:47pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/12 "2020-06-06T12:47:30Z")

</div>

Ok, so I think I managed to do this! THANK you.

---

<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: [June 6, 2020, 12:56pm UTC](https://discourse.psychopy.org/t/problem-with-seeing-typed-words-in-pavlovia/14012/13 "2020-06-06T12:56:36Z")

</div>

Cool. I don’t have easy access to my code on my phone but I know I specifically limit age responses to two digits (or 0 for prefer not to say)
