Up to this point we have only considered scenarios in which the participant makes responses by clicking buttons on the screen. Depending on the kind of stimulus that we are presenting, we used a different function:

This gives us a family of four trial types that vary depending on the stimulus modality. In jaysire (and jsPsych), we can also vary the response modality. There are three supported response methods: buttons, key presses, and slider bars. If you want users to respond by pressing a key, the jaysire package includes the following family of functions:

If you would prefer a continuous valued response that uses a slider bar:

All of these functions work in approximately the same way, but there are slightly different arguments required to describe a button press, a key press, and a slider bar.

For example, when you specify the choices in a button press trial, what you’re doing is provide a character vector that contains the labels shown on each of the buttons. In contrast, when you specifiy the choices argument for a keyboard response trial, you’re giving the a vector that specifies which keys can be used to register a response. A common use case is to ask people to press “p” to respond with their left hand or “q” to respond with their right hand, which you can do by setting choices = c("p","q"). You can also specify keys numerically by using their javascript key code value. This is worth noting, because when the data are recorded, it will be the numeric key code that appears in the data set! Also note that jaysire contains the respond_any_key() function that allows the user to press any key to register a response, and the respond_no_key() button which makes it impossible the respond with the keyboard (this is useful if you want a trial that runs for a fixed duration)

To give you a sense of how these functions work, here is a very simple experiment that uses a button press trial, a keypress trial, and a slider trial:

You can check out a working version of the experiment here.