Sensing Function Key press

Aarvee

Well-known member
Joined
Sep 21, 2005
Messages
50
Location
Bangalore, India
Programming Experience
Beginner
Hi ,

could some one help me how to sense the function key press in a form ?

I have used a statusbar panel which indicates what will be shown when a specific function key is pressed. I also included a form_keypress event where I used the e.keychar and equated to 112 ... so on ( these are ascii codes for F1 to F12 I believe ). For each of such select case I simply put a message saying the specific key was pressed.

However when I press the function keys nothing happens.

Please help.

Thanks in advance

Varadarajan R
 
For function keys, use the KeyDown or KeyUp event instead. That event receives the System.Windows.Forms.KeyEventArgs class as an argument. Use that to get the KeyCode. The function keys are all listed in that enumeration.
 
Resolved

Thanks guys,

In fact I had tried keydown and keyup earlier but it did not work.

The Keypreview did the trick. It is working.

Thanks

Varadarajan R
 
Back
Top