title: How can I get rid of character repeat delay in C#?
body: <p><a href="http://www.microsoft.com/windowsxp/using/accessibility/characterrepeatrate.mspx" rel="nofollow noreferrer">http://www.microsoft.com/windowsxp/using/accessibility/characterrepeatrate.mspx</a> - There's an option in Windows for setting repeat delay. It means the delay between first keystroke and the other ones if one keeps pressing the key. I'm creating a sort of game and I need to get rid of this "feature". </p>
  
  <p>So far I've managed to find this method:</p>
  
  <pre><code>
  
  [DllImport("user32.dll")]
  static extern ushort GetAsyncKeyState(int vKey);
  
  public static bool IsKeyPushedDown(Keys keyData)
  {
     return 0 != (GetAsyncKeyState((int)keyData) & 0x8000);
  }
  </code></pre>
  
  <p>But the method IsKeyPushedDown finds out if the key is pressed AT THE MOMENT of calling the function - so I need a loop to test if key is down. Problem is that still it doesn't catches all keystrokes - I have too slow loop I guess.</p>
  
  <p>Second choice is overriding of ProcessCmdKey:</p>
  
  <pre><code>
  protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
  {
    // processing keys
              if (keyData == Keys.Left || keyData == Keys.Right || keyData == Keys.Up || keyData == Keys.Down)
              {
                  return true;
              }
              else
              {
                  return base.ProcessCmdKey(ref msg, keyData);
              }
  
  }
  </code></pre>
  
  <p>this works really good but it's affected with repeat delay and therefore movement of my monster in my game is like: </p>
  
  <p>Is there a solution for my problem?
  Thanks</p>
  
  <p>EDIT: I solved the problem by combining both procedures. But it's very ugly solution. I still hope there's better solution. </p>