
WinForms and keyboard
Posted Sunday, 11 December, 2011 - 13:13 by puklaus inHi. Im using GLControl in winforms and not sure how I am using keyboard. Now I have event-based system
(and dont like it, must say), can I use something like with GameWindow, ie
if(Keyboard[Key.Esc]) { break; } ?
Some my code, is this even right?
private void glControl1_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyData) { case Keys.A: keyAction[0] = true; break; // more cases.. } } private void glControl1_KeyUp(object sender, KeyEventArgs e) { switch (e.KeyData) { case Keys.A: keyAction[0] = false; break; // more cases.. } } // called from Paint or some idle loop void Render() { if(keyAction[0]) x--; }
Much code to do so simple thing... and if I hold shift when pressing A, and then release A, it wont call KeyUp.


Comments
Re: WinForms and keyboard
Well I found solution
http://stackoverflow.com/questions/1100285/how-to-detect-the-currently-p...
and KeyMessageFilter example works fine.