📄 kb_b.m
字号:
%enterKey=KbName('Return');
%while 1
% [ keyIsDown, seconds, keyCode ] = KbCheck;
%if keyCode(enterKey)
% startSecs=GetSecs
% fprintf('typed at time %.3f seconds\n',startSecs);
% break;
% end
%end
KbName('UnifyKeyNames');
fprintf('\n2 of 4. Testing KbCheck timing: please type a few keys. (Try shift keys too.)\n');
fprintf('Type the escape key to proceed to the next demo.\n');
escapeKey = KbName('ESCAPE');
fid = fopen('exp1Kb.txt','a');
count=0;
while KbCheck; end % Wait until all keys are released.
while 1
% Check the state of the keyboard.
[ keyIsDown, seconds, keyCode ] = KbCheck;
% If the user is pressing a key, then display its code number and name.
if keyIsDown
% Note that we use find(keyCode) because keyCode is an array.
% See 'help KbCheck'
count=count+1;
fprintf(fid,'%i\t %s\t %12.8f\n',count, KbName(keyCode), seconds);
fprintf('%i "%s" typed at time %.3f seconds\n', count, KbName(keyCode), seconds);
if keyCode(escapeKey)
break;
end
% If the user holds down a key, KbCheck will report multiple events.
% To condense multiple 'keyDown' events into a single event, we wait until all
% keys have been released.
while KbCheck; end
end
end
fclose(fid);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -