Keypress WITHOUT textbox.. HELP
-
I am making a screensaver of sorts and I am trying to detect when p,P, or escape key is pressed. When i would hit p the screensaver would stop but upon hitting p again it should have started up again but had no response so i changed it to this. construct... this.KeyUp += new KeyEventHandler(OnKeyPress); ... public void OnKeyPress(object o, KeyEventArgs e) { switch(e.KeyCode) { case Keys.Escape: Application.Exit(); break; default: break; } } all the examples i was able to locate show using a frikin textbox... i just want the form to check and handle necessary actions required. codemonkey aspiring programmer
-
I am making a screensaver of sorts and I am trying to detect when p,P, or escape key is pressed. When i would hit p the screensaver would stop but upon hitting p again it should have started up again but had no response so i changed it to this. construct... this.KeyUp += new KeyEventHandler(OnKeyPress); ... public void OnKeyPress(object o, KeyEventArgs e) { switch(e.KeyCode) { case Keys.Escape: Application.Exit(); break; default: break; } } all the examples i was able to locate show using a frikin textbox... i just want the form to check and handle necessary actions required. codemonkey aspiring programmer
Hi I do not know if I'm get it right but from what you say : there is property of the form which when you set it to true also the form keypressed and key up key down raises . frmMain.KeyPreview = true ; then you can use form 's event to handle what you want.