Capturing Keypress - No Keycode property available ??

  • Thread starter Thread starter sULs
  • Start date Start date
S

sULs

Hi all

Hoping someone can help !!

I am trying to catch F2 - 6 key presses in a winforms application

Code as follows

private void frmMain_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
/*MessageBox.Show(e.KeyChar.ToString());*/

if(e.KeyCode == Keys.F2 )
MessageBox.Show("F2");
}

Now e is capturing the keypress fine (the messagebox works fine for
alpha\numeric) , however property wise for e i only have

KeyChar
Handled
and the usual tostring() etc

Thus can not test for keys.F2 as i have no e.Keycode ..(the
if(e>keyCode does not work )

Any ideas anyone ? Sure Im missing something simple but cant see it.

TIA Dave
 
Appears I DO have the required properties on Keydown and Keyup events
which guess is good enough !!
 
Back
Top