Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Keypress WITHOUT textbox.. HELP

Keypress WITHOUT textbox.. HELP

Scheduled Pinned Locked Moved C#
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pgfraz
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • P pgfraz

      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

      M Offline
      M Offline
      MasudM
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups