Thanks you,
Jens
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
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;
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