Having a issue with previous and current state of keys


#1

I am trying to implement a keyboard that will allow me to check a key press. "Previous state was up and Current State is down"
If I hammer the keyboard really fast the event will eventually pop, but its so random and not working as expected.

// Keyboard Update
void Keyboard::update()
{
memcpy(m_previousState, m_currentState, this->length);
SDL_PumpEvents();
m_currentState = SDL_GetKeyboardState(NULL);
}
// Key Pressed
bool Keyboard::keyPressed(int key)
{
if (m_currentState[key] && !m_previousState[key])
return true;
else
return false;
}


#2

Problem fixed.
I was also using Events which was causing a conflict.