Windows Key Delay?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Griffen25
    New Member
    • Oct 2006
    • 1

    Windows Key Delay?

    howdy, i'm currently teaching myself VB-6.0 and i'm having some troubles of mine with a simple game of "Pong" hehe

    My Problem:

    I've mannaged to bind A & Z to up and down respectivly, but my problem is Windows Key Delay, i am "unable" to hold down A or Z without waiting about 1sec before a continous movement occurs, and if any other buttons are pressed instantly the movement of the image stops.

    Can anyone out there please help me with a code to allow me to hold A or Z and instantly allow continous movement for my image?
  • albertw
    Contributor
    • Oct 2006
    • 267

    #2
    Originally posted by Griffen25
    howdy, i'm currently teaching myself VB-6.0 and i'm having some troubles of mine with a simple game of "Pong" hehe

    My Problem:

    I've mannaged to bind A & Z to up and down respectivly, but my problem is Windows Key Delay, i am "unable" to hold down A or Z without waiting about 1sec before a continous movement occurs, and if any other buttons are pressed instantly the movement of the image stops.

    Can anyone out there please help me with a code to allow me to hold A or Z and instantly allow continous movement for my image?
    hi
    try the statement 'doevents' in your keypress sub.
    this may refresh the new situation

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by albertw
      hi
      try the statement 'doevents' in your keypress sub.
      this may refresh the new situation
      My guess is you're using the wrong events. KeyDown and KeyUp may be more helpful than KeyPress. They will let you track when each key is pressed and released, even if they overlap (two players, perhaps).
      I've just tested this, and found that KeyDown keeps repeating much like KeyPress. But just ignore the duplicates (same KeyCode value) and wait for KeyUp.

      Comment

      Working...