Cannot read property 'status' of undefined - related to key responses

URL of experiment:

Description of the problem:
My experiment works locally and begins well enough online, but then I get the error message, “TypeError: Cannot read property ‘status’ of undefined”. The issue seems to be with reading the status of one of the key responses (key_resp_2). However, I don’t know how it is set up any differently from the preceding keypresses, which work fine. I do have separate (each frame) code that uses the length of key_resp_2.keys to determine the position of a line (the participant is supposed to press keys to move the line up). I am using PsychoPy 3.1.5 and Chrome.

The status error shows up right at the beginning here:

// *key_resp_2* updates
  if (t >= 0 && key_resp_2.status === PsychoJS.Status.NOT_STARTED) {
    // keep track of start time/frame for later
    key_resp_2.tStart = t;  // (not accounting for frame time here)
    key_resp_2.frameNStart = frameN;  // exact frame index
    key_resp_2.status = PsychoJS.Status.STARTED;
    // keyboard checking is just starting
    psychoJS.window.callOnFlip(function() { key_resp_2.clock.reset(); }); // t = 0 on screen flip

The added code block that references key_resp_2 is:

y = key_resp_2.keys.length/200 - .4 ;
line_position = [-.35, y];

if (y >= line_pos) {
    return Scheduler.Event.NEXT;

The polygon (line) then uses “line_position” for the shape’s position and is set to update every frame.

Thank you for any help!

Hi There,

The main difference I can see between your ‘key_resp_2’ component and previous keypresses is that the ‘force end routine’ option is not selected on that component - is it the case that this option should be selected?


Hi @Becca, thanks for your response!

Thanks for catching this difference, but it is correct as-is. The task is only supposed to move on after the participant has moved the line (using multiple keypresses) up to a certain height/position. The second block of code (above) is my attempt at doing this.