title: Find out if a button is being held using Windows Messages
body: <p>I have a program that uses windows messages to know if a button is being clicked or not : </p>
  
  <pre><code>IntPtr GetMsg(int nCode, IntPtr wParam, IntPtr lParam)
      {
          if (nCode &gt;= 0 &amp;&amp; wParam == (IntPtr)WM_KEYDOWN)
          {
              int vkCode = Marshal.ReadInt32(lParam);
  
              if ((Keys)vkCode == Keys.SomeKey)
              {
                  /*Functions*/
              }
           }
       }
  </code></pre>
  
  <p>The buttons can be pressed anywhere and the program will still handle them.</p>
  
  <p>Problem is, whenever a user is holding down a certain button, the function that the button does is repeated a lot of times in a short period of time. And even though the function is not that heavy - its still causes the computer to freeze or work slow for a couple of seconds.</p>
  
  <p>If I know that the button is being held, I would simply do the function once.</p>
  
  <p>Is there a flag or something in a windows message that indicates that the button is being held? </p>