Solution 04 (code in its own file)ΒΆ

Presuming that you followed on from the exercise in section 02, you should have a HTML file called experiment.html that looks like this:

<html>
    <head>
        <title>s04</title>
        <script src="https://unpkg.com/jspsych@8.0.2"></script>
        <script src="https://unpkg.com/@jspsych/plugin-image-keyboard-response@2.0.0"></script>
        <script src="experiment.js"></script>
        <link href="https://unpkg.com/jspsych@8.0.2/css/jspsych.css" rel="stylesheet" type="text/css" />

        </head>
    <body></body>
</html>

and a JavaScript file called experiment.js that looks like this:

var jsPsych = initJsPsych();

var trial = {
    type: jsPsychImageKeyboardResponse,
    stimulus: 'nasa_proxima.png'
};

jsPsych.run([trial]);

As before this may differ in small details like the file paths.

Remember that for this to work the image file must also be in the same folder.