keyPress

 elements

A response handler element that records subject response by key press. Also works with other keyboard-like devices. At default waits for one press of any key, then records response and ends on its own (so you don't need to set property end unless you want it to end earlier).

Response values generated are key numbers. Key numbers depend on your operating system. The little tool KbShow is an easy way to find them at the MATLAB command line. See also Psychtoolbox KbName.

You can also use keyPress elements to listen for trigger signals from an external device like a scanner that arrive as keyboard inputs. To do this set registerTrigger = <cd>true<cd> to register inputs as triggers instead of responses from subject. You can set elements in the same trial to start/end from either responses or triggers (element properties start/end). However, for triggers you can also set later trials to start at fixed times from trigger with zero drift (trial object property start).

For any trial you define in an experiment script, you can make one or more 

keyPress

 objects using function 

keyPress

Object and input them to addTrial.

For any trial you define in an experiment script, you can make one or more 

keyPress

 objects using function 

keyPress

Object and input them to addTrial.

Input properties

Adjustable properties

You can allow the subject to adjust the following input properties of an object of this type during the experiment using an adjuster element. If you need to make other properties adjustable, you can copy the element type using newPbType and edit it.

position
nn_eyes
rotation
opacity

(None)

(None)

n_device

Default: default device, generally the keyboard

<cd>[]<cd> = default device according to Psychtoolbox, which is generally the keyboard. Usually this is all you need to know.

Optionally you can listen for input from some other keyboard-like device. n_device is HID device number to listen to. You can use Psychtoolbox functions GetKeyboardIndices or PsychHID('Devices') to see available device numbers. A keyPress element uses Psychtoolbox KbQueueCreate if useQueue below = <cd>true<cd>, or KbCheck if useQueue = <cd>false<cd>. n_device goes to the input of one of those functions. See help for these functions if you need more information on device numbers.

nn_listenKeys
nn_ignoreKeys

Default: listen to all keys

nn_listenKeys is a row vector of key numbers (see above) to listen to. <cd>[]<cd> = all.

nn_ignoreKeys is a row vector of key numbers to ignore. <cd>[]<cd> = none. If you leave nn_listenKeys = <cd>[]<cd>, you can listen to all keys except the ones you specify in nn_ignoreKeys.

Note this is before responses are received, so these are always key numbers, even if you use property translateResponse to record responses as other values.

useQueue

Default: use keyboard checking for responses, queueing for triggers

<cd>true<cd>/<cd>false<cd>: There are two methods a keyPress element can use to get inputs: continuously listening for key presses in the background and logging them in a "queue" to be retrieved once per frame (<cd>true<cd>), or directly checking key up/down states once per frame (<cd>false<cd>). The checking method is simpler and has some minor advantages, but it can miss inputs that are so brief that they last (key is down) less than one frame (e.g. ≈ 17 msec at 60 frames/sec, but longer if your system drops frames due to load). The queueing method may have slightly better time measurement precision and never misses an input. Checking is usually sufficient for responses. Queueing is better for triggers from devices (registerTrigger = <cd>true<cd>) where missing a trigger could hang your experiment.

<cd>[]<cd> (default) = use checking for responses, queueing for triggers.

Input properties all visual elements have

position

Input properties all adjuster elements have

adjust

Input properties all objects have

report
info

Record properties

PsychBench uses record properties to record information during experiments. You can't set record properties but you can see them in experiment results using input property report.