duration of keypress

Hello! I am currently working on a binocular rivalry experiment and I wish to know how I can get the duration (in seconds) for which a key was pressed, and the name of the key that was pressed. Thanks a lot. 

Look into the KbQueue functions

On Sun, Oct 22, 2017 at 9:57 PM, mkoutromanoy@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:


Hello! I am currently working on a binocular rivalry experiment and I wish to know how I can get the duration (in seconds) for which a key was pressed, and the name of the key that was pressed. Thanks a lot.




Sure I've seen them, but I can't run isolated parts from this demo to understand what they do. For example I want to know at what time a key was pressed and I have created a script by corying + pasting this: 

startSecs = GetSecs;
% wait for keydown
fprintf('Waiting for key press on the keyboard. Press and hold any key\n');
timeSecs = KbQueueWait(deviceIndex,0);
fprintf('key pressed at time %.3f seconds\n\n', timeSecs - startSecs);

I keep getting the error "Undefined function or variable 'deviceIndex'." What am I doing wrong?



On Sunday, October 22, 2017 11:16 PM, "'Diederick C. Niehorster' dcnieho@... [PSYCHTOOLBOX]" <PSYCHTOOLBOX@yahoogroups.com> wrote:


 
Look into the KbQueue functions

On Sun, Oct 22, 2017 at 9:57 PM, mkoutromanoy@... [PSYCHTOOLBOX] <PSYCHTOOLBOX@yahoogroups.com> wrote:


Hello! I am currently working on a binocular rivalry experiment and I wish to know how I can get the duration (in seconds) for which a key was pressed, and the name of the key that was pressed. Thanks a lot. 





Here's some more general advice you might find useful:

https://www.snoyman.com/blog/2017/10/manipulating-maintainers

-mario