# Donate Win: GetCharWithTicks.dll

**URL:** <https://psychtoolbox.discourse.group/t/donate-win-getcharwithticks-dll/1249>\
**Category:** Uncategorized\
**Created:** [December 18, 2002, 5:00am UTC](https://psychtoolbox.discourse.group/t/donate-win-getcharwithticks-dll/1249 "2002-12-18T05:00:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ingling7](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@ingling7](https://psychtoolbox.discourse.group/u/ingling7)\
**Post date:** [December 18, 2002, 5:00am UTC](https://psychtoolbox.discourse.group/t/donate-win-getcharwithticks-dll/1249/1 "2002-12-18T05:00:57Z")

</div>

andy.snyder.wrote  
  

> \>If a character is available (i.e., CharAvail) before   
> \>the GetCharWithTicks line is reached, GetCharWithTicks returns the   
> \>most current tick value, not the tick value when the character was   
> \>pressed.  
> \>

I've attached a new version of GetCharWithTicks.dll which corrects that problem. I also fixed it to return the same ASCII codes for the arrow keys as does the Mac GetChar, thanks to Frans Cornelissen for reporting that discrepancy.  
  
  
Best,  
  
Allen  
  
  

> \>Hi Allen,  
> \>  
> \>Dan Shima and I have been trying the GetCharWithTicks.dll you wrote   
> \>for Windows. If a character is available (i.e., CharAvail) before   
> \>the GetCharWithTicks line is reached, GetCharWithTicks returns the   
> \>most current tick value, not the tick value when the character was   
> \>pressed.  
> \>  
> \>Here is a short program to demonstrate this. (And it also simulates   
> \>the basic routine for which we can not use KbCheck.) On our machine,   
> \>if a key is pressed during the WaitSecs(2) period, the reaction time   
> \>is always 2000 milliseconds insetad of something less.  
> \>  
> \>clear all;  
> \>FlushEvents('keyDown');  
> \>fprintf('Press a key.\n');  
> \>starttick = GetRealTicks;  
> \>% Simulate 2 seconds of WAVRECORD command during which  
> \>% subject may or may not hit a key.  
> \>WaitSecs(2);  
> \>if (CharAvail)  
> \> disp('A key was pressed.');  
> \> [char, whentick] = GetCharWithTicks;  
> \> RT = whentick-starttick;  
> \> fprintf('Starttick is %0.0f.\n',starttick);  
> \> fprintf('Whentick is %0.0f.\n',whentick);  
> \> fprintf('Reaction Time is %0.0f milliseconds.\n',RT);  
> \> disp('Reaction Time seems to always be 2000 milliseconds.');  
> \>else  
> \> disp('No key was pressed during 2 seconds.');  
> \>end  
> \>  
> \>   
> \>
