Records How long you hold each key down for and records an works out at the end.
Code://Type and it will record, To view the results press Control. Const Display = True; var a: String; function HeldFor(c: Char): Integer; var e: Integer; begin e:= GetSystemTime; while (IsKeyDown(c)) do Wait(1); Result:= (GetSystemTime-e); end; procedure WaitForKeys; var i, c, g: Integer; begin repeat for i:= 1 to Length(a) do begin if (not(IsKeyDown(StrGet(a, i)))) then c:= c + 1; end; if (c >= Length(a)) then Exit; g:= g + 1; until(g >= 5); end; var i, t: Integer; var Ct: array of Integer; var s: string; begin a:= 'abcdefghijklmnopqrstuvwxyz '; SetarrayLength(Ct, 1); WaitForKeys; ClearDebug; repeat for i:= 1 to Length(a) do begin if (IsKeyDown(strget(a, i))) then begin Ct[GetarrayLength(Ct)-1]:= HeldFor(Strget(a, i)); if (Display) then Writeln('Held ' + Strget(a, i) + ' For ' + Inttostr(Ct[GetarrayLength(Ct)-1]) + ' Ms.'); SetarrayLength(Ct, GetarrayLength(Ct) + 1); Status('Last Pressed ' + Strget(a, i)); s:= s + Strget(a, i); end; end; until(IsFunctionKeyDown(1)); for i:= 0 to GetarrayLength(Ct)-1 do begin t:= t + Ct[i]; end; if (Display) then Writeln(' '); Writeln('Typed ' + s); Writeln('Average Key Hold ' + Inttostr(t/GetarrayLength(Ct)-1) + ' Ms p/Key.'); end.





Reply With Quote









