-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponse.m
More file actions
34 lines (32 loc) · 1.04 KB
/
Response.m
File metadata and controls
34 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [key, RT, escape] = Response(target_SOT)
% Enable unified mode of KbName, so KbName accepts identical key names on
% all operating systems:
KbName('UnifyKeyNames');
while 1
s = GetSecs;
if s <= target_SOT + 2
rightKey = KbName('RightArrow');
leftKey = KbName('LeftArrow');
escapeKey = KbName('ESCAPE');
[keyIsDown, secs, keyCode, ~] = KbCheck;
if keyIsDown
if keyCode(leftKey) || keyCode(rightKey)
escape = 0;
key = KbName(keyCode); % unified key name
RT = secs-target_SOT; % in seconds
break
elseif keyCode(escapeKey)
escape = 1;
key="escape key was pressed";
RT=-1;
break
end
end
else
escape = 0;
key="no key was pressed";
RT=secs-target_SOT;
break
end
end
end