# TypeError: event is undefined

**URL:** <https://discourse.psychopy.org/t/typeerror-event-is-undefined/13026>\
**Category:** Online experiments\
**Created:** [May 5, 2020, 2:44pm UTC](https://discourse.psychopy.org/t/typeerror-event-is-undefined/13026 "2020-05-05T14:44:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![obemar](https://avatars.discourse-cdn.com/v4/letter/o/839c29/32.png) [@obemar](https://discourse.psychopy.org/u/obemar)\
**Post date:** [May 5, 2020, 2:44pm UTC](https://discourse.psychopy.org/t/typeerror-event-is-undefined/13026/1 "2020-05-05T14:44:11Z")

</div>

URL of experiment: [https://gitlab.pavlovia.org/obemar/masterarbeit](https://gitlab.pavlovia.org/obemar/masterarbeit)

Description of the problem:

Hi everyone,  
When piloting my experiment online, I get the _TypeError: event is undefined_ message. It appears after I press space on the welcome screen to get to the next trial/routine (4 sociodemographic questions, setting every repeat).

Could anyone tell me how to solve this? I have no plan how to handle this. Searching the forum wasn’t helpfull.  
Maria

---

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [May 5, 2020, 3:22pm UTC](https://discourse.psychopy.org/t/typeerror-event-is-undefined/13026/2 "2020-05-05T15:22:38Z")

</div>

@obemar, looks like an auto-translate issue with your custom keyboard code, where the translator has not quite converted your calls to the event module to the valid PsychoJS equivalent. You need to

```auto
// Swap
event.clearEvents("keyboard");
// with 
psychoJS.event.clearEvents();

```

Also, your call to event.getKeys should be:

```auto
psychoJS.eventManager.getKeys()

```

However, it looks like you are using a typed response for your experiment, so I would just adapt the textInput demo code without using auto-translate. See

[https://run.pavlovia.org/demos/textinput/html/](https://run.pavlovia.org/demos/textinput/html/)

> **[demos / textInput](https://gitlab.pavlovia.org/demos/textinput/)**
>
> Text Input using text and code component ======================================== This is a simple demonstration showing how to take keyboard inputs and present them on screen using a text component. You will...

---

<div class="post-metadata">

**Author:** ![obemar](https://avatars.discourse-cdn.com/v4/letter/o/839c29/32.png) [@obemar](https://discourse.psychopy.org/u/obemar)\
**Post date:** [May 5, 2020, 4:19pm UTC](https://discourse.psychopy.org/t/typeerror-event-is-undefined/13026/3 "2020-05-05T16:19:17Z")

</div>

I see, that solved it, thank you.

I used and adapted the code from the textInput demo but apparently I forgot to change auto-\> JS to Both when one time I made changes. I had a look again and put everything right, never would have come to that solution on my own. Thank you again, it works perfectly fine now.
