Keypress Event Handler linked to the Form itself.
Posted on 2007-07-26
Is there a way to give the form itself a KeyPressEventArgs?
I am writing a program for individuals with learning disabilities. Part of the design philosphy of the form is to have as little as possible that is clickable. Therefore they can't click into an area that they shouldn't. This is needed since their coordination with a mouse is very poor. That is the purpose of the application.
So, having a menu & minimize and maximize buttons are kind of a bad thing. In my application, the only things clickable is the "close program" X button in the top right hand corner, and the buttons that I coded in.
What I'm looking to do is create a keyboard shortcut. This Keyboard shortcut will then open up the "setup" form where different aspects of the application can be modified.
This is what I tried...
// In the Initialize Compenent section.
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Keyboard_Press);
// Then down below that...
private void Keyboard_Press(object sender, System.Windows.Forms.KeyPressEventArgs e)
Setup frmSetup = new Setup();
This should open up a Setup Form whenever any key is pressed, no? However nothing happens. I even put a debug break in there, and the program never pauses to go into debug mode.
I guess that means that the form never trully ever had control.
Anyone have any ideas?