Memorandums

知覚・認知心理学の研究と教育をめぐる凡庸な日々の覚書

kbDemo in PsychDemos

2005-06-11 | PsychToolBox
キーボードからの入力(およびキーコード取得)と反応時間計測のサンプル with MATLAB

% 3. Wait for a key with KbWait.
WaitSecs(0.5);
fprintf('?n3 of 4. Testing KbWait: hit any key. Just once.?n');
startSecs = GetSecs;
timeSecs = KbWait;
[keyIsDown,t,keyCode] = KbCheck;
% The initial 1 in the fprintf is needed. Otherwise '5%' won't print.
fprintf(1,'"%s" hit at time %.3f s?n',KbName(keyCode),timeSecs-startSecs);
FlushEvents('keyDown'); % discard all the chars from the Event Manager queue.
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする