How do i check if a key has been pressed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mague
    New Member
    • May 2007
    • 137

    How do i check if a key has been pressed

    Hey,


    Ive searched the internet but havnt found anything. Im making a program whicih will repeat typing text which has been entered. BUT to start it they click on the client and click Ctrl R to start the only problem is i dont know how to make it do that! if som1 could help me i would appresiate it alot. Please dont call me a noob (i no i em) also im only 13 so yea!



    Ty Mague
  • SammyB
    Recognized Expert Contributor
    • Mar 2007
    • 807

    #2
    Originally posted by Mague
    Hey,


    Ive searched the internet but havnt found anything. Im making a program whicih will repeat typing text which has been entered. BUT to start it they click on the client and click Ctrl R to start the only problem is i dont know how to make it do that! if som1 could help me i would appresiate it alot. Please dont call me a noob (i no i em) also im only 13 so yea!



    Ty Mague
    Assuming you are using VB.Net, use the form's KeyDown Event:
    [code=vb]
    Private Sub Form1_KeyDown(B yVal sender As System.Object, ByVal e As System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyDown
    If e.KeyData = (System.Windows .Forms.Keys.Con trol + System.Windows. Forms.Keys.R) Then
    MessageBox.Show ("Start")
    End If
    End Sub
    [/code]

    Comment

    • Mague
      New Member
      • May 2007
      • 137

      #3
      Thank you so much!!!! You have helped me heaps

      Comment

      • Mague
        New Member
        • May 2007
        • 137

        #4
        Ive still got a Problem i tried to out this code in and it still didnt work. It had no errors (mistakes (cant spell)) but when i ran the program and pressed the button nothing happened

        Comment

        • Mague
          New Member
          • May 2007
          • 137

          #5
          Woops soz i accidently typed wrong :( Its working perfectly :)

          Comment

          • Helmer
            New Member
            • May 2007
            • 10

            #6
            hey if u can get a chart for the keycodes of the keys on a keyboard, im sure u are all familiar with a case statement...
            form keydown event

            select case Keycode
            case vbkeyX' x=keycode
            here u put wat u want t happen wen that key is hit
            case vbkeyY y=keycode
            here u put wat u want t happen wen that key is hit
            end select

            for most keys the keycode is the keyname ex K's keycode is vbkeyK, etc

            Comment

            Working...