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 on any attached keyboard, then records response and ends on its own. Response values generated are numbers corresponding to keys pressed—see property listenKeyNames below.
You can also use keyPress elements to listen for synchronization 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, and n_device below to specify the device to listen to. Most commonly then set syncExperiment = <cd>true<cd> to tell the element to synchronize the experiment at trigger. You can then set the timing of any element in the trial (element properties start/end field t_sync) and/or subsequent trial timing (trial object property start field t_sync) from sync.
See also textInput elements.
By default yes, when it records one response/trigger. You can change number of responses/triggers to wait for in property maxNumResponses. If you set maxNumResponses = <cd>inf<cd>, records indefinitely until a condition you set in property end.
"Ends on its own" means ends automatically at that point. If an element can end on its own, you don't need to set end conditions for it in property end (unless you want it to maybe end earlier).
No—runs until any condition you set in property end.
listenKeyNames
ignoreKeyNames
n_device
useQueue
All visual elements
position
depth
nn_eyes
rotation
flipHorz
flipVert
colorMask
alpha
intensity
contrastMult
convolution
shader
filterOrder
filterGrayscale
filterResolutionMult
filterGamma
channelResolution
backColor
addDisplay
All visual elements
position
All adjuster elements have
adjust
All response handler elements
translateResponse
scoreResponse
correctResponse
scoreResponseForStaircase
maxNumResponses
recordDefaultResponse
registerTrigger
autoResponse
autoResponseLatency
All elements
start
end
startBuffer
endBuffer
vary
staircase
All objects
info
report
Default: listen to all keys; response values are operating system-dependent key numbers
Alternatively you can set this property to a vector of numbers that are key numbers. These are the same as used by Psychtoolbox functions like KbCheck. Note key numbers are different across operating systems. You can also use showKey to see numbers.
Either way, response values generated by the keyPress element are numbers corresponding to the order of the keys you list in this property. e.g. listenKeyNames = <cd>[<cd><cds>"left" "right"<cds><cd>]<cd> → response value 1 = left arrow key, 2 = right arrow key. Or if you leave listenKeyNames at default = listen to all keys, response values are just the operating system-dependent key numbers.
Default: don't ignore any keys
Like listenKeyNames above except keys to ignore. If you leave listenKeyNames at default, you can listen to all keys except the ones you list here.
Default: listen to all attached keyboards if you leave registerTrigger and useQueue at default, else default keyboard
Note if you set registerTrigger or useQueue below = <cd>true<cd> then a keyPress element can only listen to one device and default becomes the single default keyboard according to Psychtoolbox. In this case if that device is not what you want, you must specify the device you want here.
Default: use polling if you leave registerTrigger at default, else keyboard queue
At default a keyPress element uses polling by Psychtoolbox KbCheck. If you set registerTrigger = <cd>true<cd>, it uses a keyboard queue (Psychtoolbox KbQueueCreate, etc.) instead. In unusual cases you may want to override these defaults by setting useQueue = <cd>true<cd>/<cd>false<cd>.
You can vary or allow the subject to adjust the following properties of an object of this type when it's running. If you need to make other properties adjustable, you can edit the element type code—see Element Type Programming Manual.
position
nn_eyes
rotation
colorMask
alpha
intensity
contrastMult
drawCodeVars
(None)
(None)
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.
All response handler elements
response
responseScore
responseTime
responseLatency
d_responseTime
numResponses
All elements
startTime
endTime
duration
n_startFrame
n_endFrame
startLatencyBufferable
endLatencyBufferable