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. key input

key input

Scheduled Pinned Locked Moved C#
csharpquestion
4 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.
  • X Offline
    X Offline
    xxmikexx
    wrote on last edited by
    #1

    i am working on a program for school and it requires key input so when i press the "a" key a block of code will execute i would i do this i am using visual C# 2005 express edition i think it is something like Key_Down but i couldnt get it to work thanks is there somethat will run as long as the key is held down? thanks mike

    D 1 Reply Last reply
    0
    • X xxmikexx

      i am working on a program for school and it requires key input so when i press the "a" key a block of code will execute i would i do this i am using visual C# 2005 express edition i think it is something like Key_Down but i couldnt get it to work thanks is there somethat will run as long as the key is held down? thanks mike

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      xxmikexx wrote:

      i think it is something like Key_Down but i couldnt get it to work

      You handled the KeyDown event of which control or form?? If it's the form, did you also set the form's KeyPreview property to true?

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      X 1 Reply Last reply
      0
      • D Dave Kreskowiak

        xxmikexx wrote:

        i think it is something like Key_Down but i couldnt get it to work

        You handled the KeyDown event of which control or form?? If it's the form, did you also set the form's KeyPreview property to true?

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        X Offline
        X Offline
        xxmikexx
        wrote on last edited by
        #3

        ya i am working on something so while the "d" key is held down something will happen how would i do this i tried putting it in a button with a tutorial i found but it didnt seem to work it was something like private void cmdright_KeyDown(object sender, EventArgs e CHANGED SOMETHING HERE)

        D 1 Reply Last reply
        0
        • X xxmikexx

          ya i am working on something so while the "d" key is held down something will happen how would i do this i tried putting it in a button with a tutorial i found but it didnt seem to work it was something like private void cmdright_KeyDown(object sender, EventArgs e CHANGED SOMETHING HERE)

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          The problem is that you used a button, which doesn't have the input focus for very long. Handle the KeyDown event of the Form.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          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