Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Keyboard delay and refresh rate

313 views
Skip to first unread message

Jens Gruschel

unread,
Aug 29, 2004, 12:44:44 PM8/29/04
to
Is there some API call to get the keyboard delay and refresh rate (in msec)?

Thanks you,

Jens


Rob Kennedy

unread,
Aug 29, 2004, 2:45:57 PM8/29/04
to
Jens Gruschel wrote:
> Is there some API call to get the keyboard delay and refresh rate (in msec)?

I don't think keyboards have refresh rates. You can get the delay and
the repeat rate with the SystemParametersInfo API function. Use the
spi_GetKeyboardDelay and spi_GetKeyboardSpeed values. The return values
aren't in milliseconds. They're just relative values. The exact time
depends on the hardware.

--
Rob

John McTaggart

unread,
Aug 29, 2004, 3:58:29 PM8/29/04
to
> > I don't think keyboards have refresh rates.
>
> Sorry, repeat rate, that's what I meant.

These may, or may not help..

John McTaggart

//-------------
function GetKeyDelay: Integer;
var
I: LongBool;
Value : Integer;
begin
I:= SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, @Value, 0);
Result := Value;
end;

function GetKeySpeed: Integer;
var
I: LongBool;
Value: Integer;
begin
I := SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, @Value, 0);
Result := Value;
end;

procedure SetKeyDelay(Value: Integer);
var
I: LongBool;
begin
I := SystemParametersInfo(SPI_SETKEYBOARDDELAY, Value, Pointer(0),
SPIF_UPDATEINIFILE);
end;

procedure SetKeySpeed(Value: Integer);
var
I: LongBool;
begin
I := SystemParametersInfo(SPI_SETKEYBOARDSPEED, Value, Pointer(0),
SPIF_UPDATEINIFILE)
end;


Ndi

unread,
Aug 29, 2004, 11:08:53 PM8/29/04
to
> That's bad news. My idea was to create a button, which generates events at
> the same speed the keyboard does (increasing some value once when the
mouse
> button is pressed down and increasing it again and again if the mouse
button
> is hold). Seems like I have to use my own values, more or less as fast as
> most users are familiar with.

Even though the values are not in milliseconds, there *is* a table to
choose from. And the error is quite small for your purpose. Use the post
below (from John) for code, and translate like this:

* keyboard repeat-delay setting, which is a value in the range from 0
(approximately 250 ms delay) through 3 (approximately 1 second delay).

* keyboard repeat-speed setting, which is a value in the range from 0
(approximately 2.5 repetitions per second) through 31 (approximately 30
repetitions per second). The actual repeat rates are hardware-dependent and
may vary from a linear scale by as much as 20%

These values are just numbered values on the settings you use in BIOS
setup. You can get a list from there. But since you just want an approximate
value, you can set values as delay interval = (PhysicalDelay + 1) * 250 and
repeat interval = 1000/PhysicalInterval, taking care of the event of zero
repeat rate. Because you only use a button, an approximation is OK. But if
you're the precise type, use a more complex formula or build a table.

Depending on version, Windows defaults to 500-30 ms. Other versions might
default to other values (I can't remember exactly which is which) but most
users use either 500/30 or 250/30.

--
Andrei "Ndi" Dobrin
Brainbench MVP
www.Brainbench.com


0 new messages