Having a issue with previous and current state of keys


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);
m_currentState = SDL_GetKeyboardState(NULL);
// Key Pressed
bool Keyboard::keyPressed(int key)
if (m_currentState[key] && !m_previousState[key])
return true;
return false;


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