Capturing Cursor Keys?
-
I'm stumped. (I really am a decent MFC programmer, seriously...) I'm writing a control to move an image around. If I override KeyDown, I can capture absolutely EVERYTHING except for the four cursor keys. Everything else is captured, shift, control, insert, home, pgup, 'A', etc... private void Afix_KeyDown( object sender, KeyEventArgs e ) { switch( e.KeyCode ) { case Keys.Up: ...; break; case Keys.Down: ...; break; } } What am I doing wrong on the cursor keys?! Thanks guys!
-
I'm stumped. (I really am a decent MFC programmer, seriously...) I'm writing a control to move an image around. If I override KeyDown, I can capture absolutely EVERYTHING except for the four cursor keys. Everything else is captured, shift, control, insert, home, pgup, 'A', etc... private void Afix_KeyDown( object sender, KeyEventArgs e ) { switch( e.KeyCode ) { case Keys.Up: ...; break; case Keys.Down: ...; break; } } What am I doing wrong on the cursor keys?! Thanks guys!
You need to override the form's IsInputKey method to tell it that the cursor keys are to be handled as input. HTH, James Sonork ID: 100.11138 - Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971
-
You need to override the form's IsInputKey method to tell it that the cursor keys are to be handled as input. HTH, James Sonork ID: 100.11138 - Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971
Thanks James. Works great now. Here's the code I used to override IsInputKey protected override bool IsInputKey( Keys keyData ) { bool bIsInputKey = true; switch( keyData ) { case Keys.Left: break; case Keys.Right: break; case Keys.Down: break; case Keys.Up: break; default: bIsInputKey = base.IsInputKey( keyData ); break; } return bIsInputKey; }