I've created this form, and when the form is visible and some certain keys are pressed, I want certain things to happend. But (so far) they dont...
In the constructor of the form i have this line of code:
and i have this function relating
this would lead med to believe no matter what key is struck something will happend, but nothing happens (in ohter words the 'KnappTrykket'-function is never called. What am i missing here?
In the constructor of the form i have this line of code:
Code:
this.KeyPress += new KeyPressEventHandler(KnappTrykket);
and i have this function relating
Code:
private void KnappTrykket(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == 'k')
{ //execute some function }
//some more if/else statements and
else
{ //execute some other function}
e.Handled = true;
}
this would lead med to believe no matter what key is struck something will happend, but nothing happens (in ohter words the 'KnappTrykket'-function is never called. What am i missing here?