# kbcheck doesn&#39;t detect key release

**URL:** <https://psychtoolbox.discourse.group/t/kbcheck-doesn-39-t-detect-key-release/1591>\
**Category:** Uncategorized\
**Created:** [February 17, 2006, 10:45pm UTC](https://psychtoolbox.discourse.group/t/kbcheck-doesn-39-t-detect-key-release/1591 "2006-02-17T22:45:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [February 17, 2006, 10:45pm UTC](https://psychtoolbox.discourse.group/t/kbcheck-doesn-39-t-detect-key-release/1591/1 "2006-02-17T22:45:32Z")

</div>

Hi everyone,   
  
I need my program to detect the time period for which a key remains   
pressed, but kbcheck doesn't seem to detect the release of the key.   
I have version 2.54 (for Windows) and this problem was supposed to   
have been corrected in an earlier version, but it seems to still   
persist.  
  
Here's a sample of the code I tried:  
  
function time = keyDur()  
validPress = 0;  
while ~validPress  
 [touch, secs, keyCode] = KbCheck;  
 if strcmp(KbName(keyCode),'down')  
 startTime = KbWait;  
 kdown = 1;  
 while(kdown)  
 WaitSecs(0.01);  
 [touch, secs, keyCode] = KbCheck;  
 if strcmp(KbName(keyCode),'down')  
 kdown = 1;  
 else  
 b = KbWait;  
 kdown = 0;  
 end  
 end  
 endTime = KbWait;  
 validPress = 1;  
 end  
end  
clc;  
time = endTime - startTime;  
  
Is there something I'm missing about KbCheck? Thanks a lot,   
  
Vani
