Presenting a Stimulus on the Screen Briefly using Javascript code component

I would like to present in the online version of my task an image of a checkmark on the screen for a few seconds in response to the key presses of participants reacting to things displayed on the screen for a longer amount of time which would remain on the screen after the checkmark disappears.

When running this on my laptop, I was using a python code component:

To load the image

from psychopy import visual
check = visual.ImageStim(win, 'icon/checkmark.png')

To display the image

            check.draw()
            win.flip()
            core.wait(.15)

How would I code this into a Javascript code component?

I am facing the same problem and could not find a solution either. Hopefully someone can help us out in this matter! :slight_smile:

I think there is a javascript way to do it. You can use setTimout(function, time).

So, you can do something like:

if ((typeof response != "undefined")) {
 setTimeout(check.draw(), 150)
}

As per my crib sheet PsychoPy Python to Javascript crib sheet - Google Docs

I would

if stuff:
     check.setAutoDraw(True)
     checkDrawn=t

if checkDrawn>0 and (t>(checkDrawn+.15)):
     check.setAutoDraw(False)
     checkDrawn=0

This is Python code which should translate correctly. You’ll need to have checkDrawn=0 in Begin Experiment or Begin Routine

1 Like