Skip to main content
gamedev.net
🔒 Locked

Delphi - Keyboard Buffer

Started by hpesoj Dec 10, 2005 at 6:29 AM 2 replies 2.3k views
Original Post
hpesoj
hpesoj
I am trying to make a function that returns a string of the characters for all the keyboard keys pressed since the last time the function was called. Maybe there is already such a function, but I haven't found it. My question is how would I detect which character keys have been pressed? It is a seemingly simple question, but I have looked everywhere and all I can find is the OnKeyPress function, which seems to be part of a windows control, which is not what I want.
Joseph Thomson - CLS Productions
hpesoj
hpesoj
Bump. Any ideas anyone? I'm really quite stuck with this.
Joseph Thomson - CLS Productions
mikeman
mikeman
It's not related to Delphi really, but the Win32 API function GetAsyncKeyState() does exactly that, for one key of course(you'll have to create the buffer yourself and fill it with multiple calls to the function). GetKeyBoardState OTOH handles it all, all you've got to do is pass the buffer and it will copy the status of the 256 virtual keys to it.

You could always also try using a library for your input needs, like DX or SDL.
hpesoj
hpesoj
Ta muchly. Exactly what I needed. I also seem to remember using sdl in the past, but I need as much flexibility as possible so GetAsyncKeyState seems to do the job. Cheers.
Joseph Thomson - CLS Productions

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.