26  Components and their properties

In this chapter, we will have a closer look at three key PsychoPy components and their properties: the Text, the Image and the Keyboard component.

26.1 The Text component

The Text component icon.

Figures 26.1 to 26.4 show the basic, layout, appearance and formatting properties, respectively, of our Text component in the routine trial.1

Show/hide the figures
Figure 26.1: Basic properties of a Text component.
Figure 26.2: Layout properties of a Text component.
Figure 26.3: Appearance properties of a Text component.
Figure 26.4: Formatting properties of a Text component.

Most of the properties are probably self-explanatory. A few comments though:

  • Letter height in our example is 0.15. Without looking at the units used, you don’t know what 0.15 refers to. Information about the unit can be found on the Layout tab. In our example, it says Spatial Units: height. This means that the size of the letters will be approximately2 15% of the screen height.
  • The position is (0, 0). In PsychoPy, these are the x and y coordinates for the centre of the screen. You can learn more about this topic on this PsychoPy help page about units and using this interactive app illustrating PsychoPy units.
  • We’ll cover the exact meaning of $stim next week. Very briefly, together with the setting “set every repeat”, it means that the stimulus will be updated from one trial to the next.3

26.2 The Image component

The Image component icon.

Figures 26.5 and 26.6 show the most relevant properties of our Image component in the routine instruction.4

Show/hide the figures
Figure 26.5: Basic properties of an Image component.
Figure 26.6: Layout properties of an Image component.

Again, a few comments:

  • “Image” refers to a file name on your computer. In our example, this file is called letter_flanker_instruct.png. The image file must be located in the same directory as the experiment itself (otherwise, it would be necessary to specify the path to the image).
  • The size of the image on the screen will be 1280 x 960 pixels (see “Size” and “Spatial Units”).
  • Using the “Orientation” property, images can be rotated.

Note that leaving the size field empty will display the image in its original size in pixels.5

26.3 The Keyboard component

The Keyboard component icon.

Figures 26.7 and 26.8 show the most relevant properties of our Keyboard component in the routine trial.

Show/hide the figures
Figure 26.7: Basic properties of a Keyboard component.
Figure 26.8: Data properties of a Keyboard component.

The properties of the Keyboard component deserve some more detailed comments:

Force end of Routine: If this is ticked and the participant presses one of the allowed keys, the trial will end.

Allowed keys: These are the keys that will be registered by PsychoPy. If a non-allowed key is pressed, PsychoPy will not know about this event. To allow all keys on the keyboard, leave the “Allowed keys” field empty.

Store: The default choice for storing responses is “last key”. However, “first key” might be a better choice (if a response is incorrect, you will store the incorrect key and thus know that the response was incorrect). Note, however, that if you choose “Force end of Routine”, the result for both settings will be the same as the first response will end the trial and the first key will therefore also be the last key.

Store correct: If ticked, PsychoPy will store whether or not the answer on a given trial was correct.

Correct answer: Of course, PsychoPy cannot know what the correct answer on a given trial is. Therefore, you must supply PsychoPy with this information. $corrAns makes PsychoPy look for a column with that name in an input file you provide PsychoPy with (more about this next week).

For the remaining properties, simply leave the default values.

26.4 Components quiz

When configuring the “Allowed keys” of a Keyboard component in PsychoPy, which settings affect what responses are recorded? Select all that apply.

Regarding keyboard response recording:

  • The “Allowed keys” field does determine which keys will be registered.
  • Empty “Allowed keys” field means ALL keys will be registered.
  • Non-allowed keys are NOT recorded at all.

For an Image component, if you leave the size field empty, what will happen? Select the correct answer.

When the size field is left empty in an Image component, the image will be displayed in its original size in pixels. However, it’s important to note that this will not work when running an experiment online with Pavlovia. Pavlovia requires a defined size.

In a Keyboard component, what is the effect of the “Store” setting? Match each option with its effect:

  1. When set to “last key”:
  2. When set to “first key”:
  3. When “Force end of Routine” is also ticked:

For the “Store” setting in a Keyboard component:

  1. “last key” records the final key pressed during the component’s duration.
  2. “first key” records the first key pressed during the component’s duration.
  3. When “Force end of Routine” is ticked, both settings give the same result since the trial ends after the first response.

A Text component uses a height setting of 0.15 with spatial units set to “height”. What does this mean?

When height is set to 0.15 and spatial units are set to “height”, the letters will be approximately 15% of the screen height. The reason is that using height units the total height of the screen is by definition 1.

Note that the exact height may vary for individual letters.


  1. Usually, you will not need the other two tabs that are not shown here. Feel free to have a look at them though.↩︎

  2. Height will vary for individual letters. E.g., an “a” won’t be as high as a “d”.↩︎

  3. For comparison purposes, have a look at the Text component from the routine taskBegin. This has text that is set to “constant”.↩︎

  4. Again, we won’t need the other tabs.↩︎

  5. This does not work when running an experiment online with Pavlovia though.↩︎