Page 1 of 1
Scan Keyboard...
Posted: Fri Jul 11, 2003 7:16 pm
by Skipsy
Hello,
Sounds stupid but I can't find a (nice, clean, smart...) way for scanning
the whole keyboard.
I just need to know which key is pressed... as an window event.
For now I scan values 1 to 255 in a loop but it is a very empirical
way
Any
Thks
Posted: Fri Jul 11, 2003 9:07 pm
by tony
Never tried it before, but isn't ExamineKeyboard() designed for that?
Just a quick tought
Posted: Sat Jul 12, 2003 1:57 am
by aszid
i believe examinekeyboard() requires you to be in 3d mode. i think it relies on the directX stuffs.... i could be wrong though... but the mouse commands are like that.
Posted: Sat Jul 12, 2003 3:45 am
by Doobrey
Download the API-Guide from
www.allapi.net, and have a look at the keyboard specific stuff there.
Off the top of my head, there`s a command called GetKeyBoardState, and it fills a 256 byte buffer with the state of each key
Posted: Sat Jul 12, 2003 9:04 am
by Skipsy
Well... GetKeyBoardState fills a buffer with the state of each virtual
key.
It could help but I will also to scan the whole buffer.
I have spent a while looking for an API just returning the keycode stroke
or its ascii value. I fell it does not exist... strange
I 'll find another way,
Thks.
ww
Posted: Sat Jul 12, 2003 11:47 pm
by Doobrey
DOH..I just re-read the original question and saw the bit about window event.
Simple, set up a callback function for your window, and scan the messages for keyups and keydowns..
It only works when your window is active though.