   [.net] Keypress and Keydelay
  I've taken some free tetris sourcecode I found on the net and am looking to improve it to mimic a game I play online.The major problem I have is the code uses the keypress event, which is controlled by the windows environment. When I press an arrow key, I want to define in my code how long it should wait before executing one action, and then executing the same action repeatedly, and also define how long it should wait between the repeated actions.What I want to know is the best way to implement a user definable key delay and key repeat in my program. I imagine it would involve using timers, but I can't get my head around the concept enough.I'd be greatful for anything from a useful URL to reference to actual sourcecode I would be able to modify to suit my needs.Thanks heaps!Steve   
  In the event handlers, set a flag about the key being down, i.e.void KeyDown(object sender, KeyEventArgs e){ keyFlags[e.KeyCode] = true;}void KeyUp(object sender, KeyEventArgs e){ keyFlags[e.KeyCode] = false;}Then in your game loop process input on the basis of those flags.If you're on Windows only you can PInvoke the Windows function GetAsyncKeyState and call that for keys you're interested in within your game loop.   ;In case someone came to this thread from a search engine