Keys in a switch statement?

How can i do keyboard keys in a switch statement? For example

1
2
3
4
5
6
7
8
9
10
11
switch(option){
   case F1:
     Do whatever the hell;
break;
   case F2:
     Do whatever the hell;
break;
   default:
     Do whatever the hell;
break;
}


Im still new when it comes to windows programming so i dont know where to start with this one.
That depends on what "option" is and where you got it from...
Its just an example, like i said i have no idea where to start. Im not sure what type of data option would even need to be.
You can use the key macros.
Since you're using the Windows API (I'd hope so since you're in the Windows Programming Forum), look up handling of the Windows Virtual Keys. I believe this is exactly what you want. It will almost simulate a keyboard hook, but not quite as effective. On the plus side, it can turn the display echo off so you can output whatever you want for each key (Think of an on screen Virtual Keyboard) or handle each one as it's own event. If you know threading, you can have one thread handle the keyboard events while the other thread "responds" to the events.
Topic archived. No new replies allowed.