How can I react to a Fn keypress at the form level ?

I have implemented your answer "7.6 How can I listen for certain keys at the Form level irrespective of which Control has the focus?". Some keys are going to my code, but not all : the Fn keys, or a letter corresponding to a button shortcut do not go thru this routine. What can I do ? Thank you.

2 Replies

GT Gilbert Tordeur November 17, 2005 10:47 AM UTC

Use KeyDown instead of KeyPress. >I have implemented your answer "7.6 How can I listen for certain keys at the Form level irrespective of which Control has the focus?". Some keys are going to my code, but not all : the Fn keys, or a letter corresponding to a button shortcut do not go thru this routine. What can I do ? Thank you.


AD Administrator Syncfusion Team December 16, 2005 12:40 PM UTC

Hi Some other way using Win API declare fun like this [DllImport("User32.dll")] private static extern short GetAsyncKeyState( System.Int32 vKey); then u can use this code in timerelasped or inside a thread foreach(System.Int32 i in Enum.GetValues(typeof(Keys))){ if(GetAsyncKeyState(i) == -32767 && ActiveForm.Text=="") { MessageBox.Show(Enum.GetName(typeof(Keys), i)); } } this wil chk the key state.better place it in infinite loop. If u omit form.text check it will respond to the keypresses in other applns too.

Loader.
Up arrow icon