Here are some handy functions you may want to look at for DirectInput.

One function tests for keys being down with repeats and one only returns true if the last key pressed does not match the one you are pressing - thus no repeats.

Nice for situations in which you want to have certain keys non-repeating and certain ones to be repeating.

Examples:

Switch camera - non - repeating (too fast to be useful)
Turn left - repeating

Code:
inline bool KeyDown(UCHAR key)
{
  if (m_pKeystate[key] & 0x80) 
  {
    m_pKeyArray[key]=1;
    return true;
  } 
  else 
  {
     m_pKeyArray[key]=0;
     return false;
  }
 
}
        
inline bool KeyDownOne(UCHAR key)
{
  if (m_pKeystate[key] & 0x80) 
  {
     if (m_pKeyArray[key]==1)    //key is already down
     {
        return false;
     } 
     else 
     {
        m_pKeyArray[key]=1;
        return true;        //Key is now down
     }
  } 
  else 
  {
     m_pKeyArray[key]=0;         //Key is obviously up so reset it
     return false;
  }
}
m_pKeyArray is the same exact thing is m_pKeyState.

m_pKeyState=new UCHAR[256];

Notice that what is nice is the keys are only reset when you query them the next time. No need to reset the entire array every frame. It's state only matters when you query it. m_pKeyState is filled by DirectInput every frame so when you check it, it will reflect the current state of the keyboard.