Link to home
Start Free TrialLog in
Avatar of mince
mince

asked on

Keyboard handler (for game) with Delphi or C++ Builder

How to make a keyboard handler (usually games use it, like
doom, duke nukeem so it can run very fast) with Delphi or C++ Builder. I want to get very immediate respons when I press keyboard so I can move fastly.
Avatar of mince
mince

ASKER

Please answer my question immediately because I need it very much to complete my
study.
Hi,
Isn't "OnKeyDown"/"OnKeyUp" fast enough?

/// John
If your program should recieve (and maybe process) the keyboard message first, try a hook function (see: SetWindowsHookEx). This will gain some extra microseconds.

And of course there is DirectX 5 - DirectInput as described in Mircosoft Press's 'Inside Direct X'. But I have never tried it myself...

Generally I would recommend using 'OnKeyDown'/'OnKeyUp' as the savest and easiest solution.

. and set the repetition rate in the control panel/keyboard to maximum.

Roadrunner
Yup, as the guys told you what you should do I guess I don't need to repeat that suggestion again.... OnKeyPress/OnKeyDown/OnKeyUp/SetWindowsHookEx/UnhookWindows.....and so on.....

P.S. Especially for games I guess the Hook is better, but it's more comlex to implement.... By complex I mean that you need more, code, more though, and a DLL which should be provided with your program...

Regards,
Viktor Ivanov
though = thought, actually it's though too ;->
ASKER CERTIFIED SOLUTION
Avatar of scrapdog
scrapdog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial