|
-
Sep 10th, 2002, 04:59 PM
#1
Thread Starter
Frenzied Member
trapping keys
for school I have to make a function to trap all keys and the mouse buttons...msdn came up with nothing (again!)...the main keys are easy...
Code:
int trap()
{
int ascii = getch();
return ascii;
}
but the mouse had nothing for checking clicks....and is there a better way to get keyboard input, like every key?
this is a console app.
thanks!
(you don't have to write anything for me, just if you know any function names that would be fabulous!)
-
Sep 10th, 2002, 05:25 PM
#2
Thread Starter
Frenzied Member
ooooooooooh
BOOL GetKeyboardState(PBYTE lpKeyState);
sounds like its what I want for the keyboard at least....now anyone know how on earth to use it?
-
Sep 10th, 2002, 10:35 PM
#3
Member
Hi Steve! I decided to be really nice and solve both the keyboard and mouse problems. Here you go:
PHP Code:
#include <iostream.h>
#include <windows.h>
int main()
{
int keys[256];
// Reset all key values
for (int i = 0; i < 256; i++)
keys[i] = 0;
// Wait for the enter key or left mouse button
// to be pressed
while (keys[13] == 0 && keys[VK_LBUTTON] == 0)
for (i = 0; i < 256; i++)
keys[i] = GetAsyncKeyState(i);
// Print message
cout << "Enter or mouse button was pressed" << endl;
return 0;
}
-
Sep 11th, 2002, 06:08 AM
#4
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|